How to use SAP RFM with SAP NCo via Invoke Code in UiPath

In my next step of my experiments to connect SAP from UiPath I have set up on my results from here. Today I want to check how to call a remote enabled function module. That is much more easier than it seems. At first I developed a VBdotNET code to connect an SAP system and to call a remote enabled function module.


Dim cfgParams As SAP.Middleware.Connector.RfcConfigParameters
Dim destination As SAP.Middleware.Connector.RfcDestination
Dim rfcFunction As SAP.Middleware.Connector.IRfcFunction

cfgParams = New SAP.Middleware.Connector.RfcConfigParameters
cfgParams.Add(SAP.Middleware.Connector.RfcConfigParameters.Name, "Test" )
cfgParams.Add(SAP.Middleware.Connector.RfcConfigParameters.AppServerHost, "ABAP702")
cfgParams.Add(SAP.Middleware.Connector.RfcConfigParameters.SystemNumber, "00")
cfgParams.Add(SAP.Middleware.Connector.RfcConfigParameters.Client, "001")
cfgParams.Add(SAP.Middleware.Connector.RfcConfigParameters.User, "BCUSER")
cfgParams.Add(SAP.Middleware.Connector.RfcConfigParameters.Password, "minisap")

destination = SAP.Middleware.Connector.RfcDestinationManager.GetDestination(cfgParams)

rfcFunction = destination.Repository.CreateFunction("STFC_CONNECTION")
rfcFunction.SetValue("REQUTEXT", "Hello World from UiPath Studio via SAP")

echoText = rfcFunction.GetValue("ECHOTEXT").ToString()
respText = rfcFunction.GetValue("RESPTEXT").ToString()


In this example I call the remote enabled function module STFC_CONNECTION. At first I define the connection parameter to the SAP system. Then the import parameter is defined, it imports REQUTEXT. After the execution of the RFM it exports ECHOTEXT and RESPTEXT. As you can see ECHOTEXT is only a copy of REQUTEXT and RESPTEXT contains a few SAP system fields.

Here the flow chart, only with the Invoke Code and two Write Line activities.

And here the result :slightly_smiling_face:


My gosh, it can hardly be easier to call an SAP RFM.