Outdated: Another Way to use SAP Remote Function Calls (RFC) with UiPath

Important hint: The approach described in this post is obsolete and outdated. It is not guaranteed to work with current versions of UiPath.


One of the first results, of my contact with UiPath Studio, was the possibility to call SAP remote enabled function modules (RFMs) via PowerShell from UiPath. Now, after one month in deeper contact with UiPath, I know other interesting ways. Here is a small continuation.

At first I build my own NuGet package from the SAP dotNET Connector. I read from @vvaidya the great tip to use the NuGet Package Explorer for that. After a little time of exercise it works very good and easy.

So I build my first NuGet package and add it to my UiPath project.

And on this way I can now use SAP RFC seamlessly in UiPath. Here my first tiny experiment to get some information from the SAP dotNET connector, like Version, PatchLevel and Release.

npe004

And it works perfect :grinning:

npe005

Wow, I am each day more impressed about the possibilities of UiPath. The seamless integration of SAP RFC offers great possibilities to work with an SAP backend system and ABAP.

3 Likes

Since a few days offers SAP the new version 3.0.22.0 of the dotNET Connector. I changed the files in the NuGet package and correct the version number in the XML files.

All works well so far :slightly_smiling_face:

'-Begin-----------------------------------------------------------------

Version = SAP.Middleware.Connector.SAPConnectorInfo.Version
PatchLevel = SAP.Middleware.Connector.SAPConnectorInfo.KernelPatchLevel
Release = SAP.Middleware.Connector.SAPConnectorInfo.SAPRelease

'-End-------------------------------------------------------------------

uipath002

Here another example to get some system information.

'-Begin-----------------------------------------------------------------

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

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("RFC_SYSTEM_INFO")
rfcFunction.Invoke(destination)
RFCSI = rfcFunction.GetStructure("RFCSI_EXPORT")

'-Get a few information-------------------------------------------------
Host   = RFCSI.GetValue("RFCHOST").ToString
SysID  = RFCSI.GetValue("RFCSYSID").ToString
DBHost = RFCSI.GetValue("RFCDBHOST").ToString
DBSys  = RFCSI.GetValue("RFCDBSYS").ToString

'-End-------------------------------------------------------------------

uipath003

Main.xaml (6.7 KB)

1 Like

I try to get, how you created the Package, but i cannot figure it out. I have the NuGet Explorer and downloaded the SAP Dot Net Connector, but i cannot build a package like yours.
Is there a good tutorial on building things like this, for people that are not so firm in .Net Development?

@Ben_Ten

Hello Benjamin,
you can add a the NCo files like the following sequence.

Press right mouse button in Package contents and select Add Lib Folder.

201

After that press right mouse button on lib folder again and choose Add .NET folder and v4.0.

202

Then press right mouse button on net40 folder again and choose Add New File… and select the NCo library files.

203

All you have to do now is to fill the package metadata, press Ctrl+K to do that. You can fill here what ever you like, or do it similar to me above.

And that’s it :slightly_smiling_face:
Now you can use your package with UiPath.

Best regards
Stefan

Since the end of May offers SAP the patch level 23 of the SAP dotNET Connector NCo. This morning I build with the current version a new NuGet package, as I described above. And I tested my code.

Version = sap.Middleware.Connector.SAPConnectorInfo.Version
PatchLevel = CStr(sap.Middleware.Connector.SAPConnectorInfo.KernelPatchLevel)
Release = sap.Middleware.Connector.SAPConnectorInfo.SAPRelease

image

image

I tried it also in C#.

Version = SAP.Middleware.Connector.SAPConnectorInfo.Version;
PatchLevel = SAP.Middleware.Connector.SAPConnectorInfo.KernelPatchLevel.ToString();
Release = SAP.Middleware.Connector.SAPConnectorInfo.KernelRelease;

image

And here the other example:

//-Begin----------------------------------------------------------------

SAP.Middleware.Connector.RfcConfigParameters cfgParams;
SAP.Middleware.Connector.RfcDestination destination;
SAP.Middleware.Connector.IRfcFunction rfcFunction;
SAP.Middleware.Connector.IRfcStructure RFCSI;

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("RFC_SYSTEM_INFO");
rfcFunction.Invoke(destination);
RFCSI = rfcFunction.GetStructure("RFCSI_EXPORT");

//-Get a few information------------------------------------------------
Host   = RFCSI.GetValue("RFCHOST").ToString();
SysID  = RFCSI.GetValue("RFCSYSID").ToString();
DBHost = RFCSI.GetValue("RFCDBHOST").ToString();
DBSys  = RFCSI.GetValue("RFCDBSYS").ToString();

//-End------------------------------------------------------------------

All works well and as expected with the same result.

2 Likes

Here a tiny link collection for SAP dotNET Connector NCo.

4 Likes

Thanks, @StefanSchnell! very helpful :handshake:

2 Likes

Hi StefanSchnell,
I must tell you. Your post has been very useful in one of my projects and has been a key pillar of its success.

3 Likes

Thank you very much @rkmatieda :grinning:

As per the first post:

Important hint: The approach described in this post is obsolete and outdated. It is not guaranteed to work with current versions of UiPath.