Code Generator for the Invoke Code Activity to use SAP RFC Function Modules Easily

Complex activities can be simplified considerably by using of clever selection criteria. One example is the UiPath BAPI activity, for the SAP remote enabled function modules (RFM), with a business application programming interface. This inspired me to program a tool that offers a similar approach, but for all RFMs which are available in an SAP system.

Hint: You can find more technical information about RFC in my knowledge document, on side 9.

The interface between UiPath and an SAP system is the SAP dotNET Connector (NCo) via the Invoke Code activity.

Hint: You can find more information how to use NCo here.

Based on this knowledge, I programmed an RFM Code Generator. With this tool you can generate C# or VBdotNET code to use RFMs of an SAP back-end system. You can easily detect and select the RFM you need. With a few mouse clicks you can generate the code to call the RFM. All descriptions and interfaces, with its technical details, are visible and you can put together exactly what you need.

After starting the generator, the connection data must be entered first at the Connection tab.

After the connection has been successfully established, you can switch to the Selection tab. Here the desired function module can be easily selected and the code generated in a few steps.

  1. Type a pattern or the name of the RFM you want to use. In this example RFC*.
  2. Press this button to get all RFMs from the connected SAP system, with the pattern.
  3. Double click on the RFM name you want to use. In this example RFC_SYSTEM_INFO.
  4. Here you see the name of the RFM which was selected and the available descriptions in all languages.
  5. The RFM interface, in our case it contains only export parameters. Here you can find Import, Export, Exception and Changing parameters of the RFM.
  6. Select the programming language in which the code is to be generated. In this example VBdotNET.
  7. Press the Generate Code button to generate the code in the Code tab

If a function documentation is available, you can find it in the tab of the same name. But in the most cases RFMs are not documented.

With five tiny clicks you generate code to call an RFM in an SAP system.

With a double click on a structure you jump into the Structure Definition tab and you can see all details, in this example RFCSI_EXPORT.

This can be used to generate code for deeper structures.

  1. Select the fields you are interested in. In this example RFCHOST, RFCSYSID, RFCDBHOST and RFCDBSYS.
  2. Select Set, if you want to set the content of the fields, or Get, if you want to get the content of the fields. In this example Get.
  3. Press Generate Code to Clipboard button. The additional VBdotNET code to get the content of the selected fields is now in the clipboard available

Paste it into your code.

I invoke the code on an independent way, like I described here.

Now the code can be copied into the Invoke Code activity …

… and executed.

With this RFM Code Generator you can create C# or VBdotNET code sequences, to call SAP RFMs, easily. You very quickly gain an overview of the technical interface and can just as quickly create the basis for use. However, you must also know exactly what you are doing. The generated code can be easily transfer and use in the UiPath Invoke Code activity. This approach should reduce development times.

You can find the RFM Code Generator here, with a detailed user manual.

10 Likes

HI @StefanSchnell

:heart: AMAZING WORK DONE! :heart:

Let me try it out, looking forward to investigate this on my own!

Thank you very much for contribution!

Best regards, Lev

1 Like

@LevKushnir

Thanks a lot Lev, I’m looking forward to your results.

The current version of the RFM Code Generator contains now two search methods to find a remote enable function module.

  1. By technical name, like RFC* to find e.g. RFC_READ_TABLE

  2. Be description
    This is a reverse search via the description of the remote enabled function module. On this way, the RFM can be determined via the descriptive text, the short text of the function module.

image

With this approach, the search can be extended on another level. Depending on the quality of the description, a business perspective may be considered.

Furthermore I added two additional fields in the selection perspective, the package, aka development class and the function group.

image

image

On this way you can open the package in ABAP for Eclipse or the SE80 very fast, to find other function modules.

You can find the RFM Code Generator at my home page.

Thank you very much to @LevKushnir and @robert.wagner for the great discussions. :slightly_smiling_face:

1 Like

Great work @StefanSchnell
You are saving SAP - RPA Developers thousands of hours!

I think I told you about my testing and QA background and so of course I tried to break your tool!
Forgive me Muha ha ha

Here is what I did:
I connected with our largest/slowest SAP instance and performed a rather complex search with wildcards and specific language → I know, this was against your recommendation! :slight_smile:

While I was doing this, following things came to my mind which I thought would make the tool perfect:

  1. The search took about 20+minutes
    → so I thought a “Cancel Search” button would be awesome
  2. I had to kill the process and after restart, I had to insert connection params again
    → persist connection params would be awesome?
  3. In another search it stopped responding after about 30 minutes
    → Show some progress bar would be awesome to see if it is still active
  4. It seems the search results of “technical names” and “description” is an OR expression? I ended up sometimes with many search results
    → Would it be feasible to set the search results to an AND, OR expression? Maybe this will become very quick very complex?

This is just nice to haves - thank you so much again for this fantastic tool!
Looking forward to our next session!

Cheers
Robert

2 Likes

@robert.wagner

Hello Robert,
thank you very much for your suggestions.

The current release contains …

  1. a cancel search button, to break a search as fast as possible.
    image

  2. a file called RFMCodeGen.Connection.xml to persist your connection data.

  3. in the status bar of the window the status of proceeding.
    image

  4. No, it is an AND clause, otherwise it would not make sense.

Best regards
Stefan

1 Like

A new release of RFM Code Generator is available. The new features are …

… the data element from a component of a structure is additionally determined now. This is on the one hand interesting to know and on the other hand necessary to know if the structure contains nested tables or structures.

… the possibility to export the information and structures as Microsoft Excel file.

Here e.g. the interface of RFC_READ_TABLE.

@LevKushnir Here I add the DefaultValue :slightly_smiling_face:

And here the different tables.

This structure follows exactly that of the UiPath SAP Accelerators.

You can find the link to the RFM Code Generator at the end of the first post of this thread.

1 Like

I :heart: the new “Export to Excel” feature! Looks really good!

1 Like

After the global event about SAP API Automation with the help of UiPath I had a lot of discussions about the most common API use case in relation with SAP. It seems to be reading data from tables. Therefore I decided to extend the RFM Code Generator to support this possibility in a simple way.

The current release of the RFM Code Generator contains the possibility to generate code for the RFM RFC_READ_TABLE. In the tab ReadTable it is possible to select an SAP transparent table or an SAP view to get the data from it. Type the table or view name in the search field, wildcards are supported, and select with a double click the object you need.

After the double click you can find the name and available descriptions in the text field. And you see development class or package of the table. Below the list the sum of the length of all fields is displayed and the hint, that the RFM RFC_READ_TABLE return value must not exceed a length of 512 characters. In the list you see the fields of the table with its details.

It is possible to select the fields you need. This means that only the selected fields are considered when generating the code.

To generate code to use the table choose the programming language you want to use, C# or VBdotNET. Press the button “Generate Code” and now in the tab Code a code sequence is available.

With this option there is the possibility to create C# or VBdotNET code, for the Invoke Code activity, to read SAP data direct into a data table. On this way, with a few mouse clicks, a code sequence can be generated that reads data from an SAP table which can be used with UiPath.

You can find the link to the RFM Code Generator at the end of the first post of this thread.

3 Likes

Great evolution of the tool. Completely agree “Extract Data from Table” is the most required discipline. Thanks, @StefanSchnell !

1 Like

Thank you very much @LevKushnir :slightly_smiling_face: