How to work with SAP

Robocorp supports automating SAP.

Which SAP product and version do I need to access

Depending on the SAP product and version you may need to use different libraries. The best way to access SAP would be API interface (if possible) and for that purpose you can use either RPA.HTTP library or directly using Python's requests package.

Currently Robocorp has a specific support for SAP GUI Windows application, which can be automated with the RPA.SAP library.

The SAP GUI has applications for Java and HTML. The Java can be automated using RPA.JavaAccessBridge library and HTML application using browser automation libraries like RPA.Browser.Selenium or RPA.Browser.Playwright.

Please note:

SAP GUI for HTML and SAP GUI for Java do not have all the capabilities of SAP GUI for Windows. Some applications such as SAP BI or SAP SCM require the SAP GUI for Windows. You find more information in the Master Guides for the relevant SAP products.

See SAP GUI for more detailed information.

Example implementation:

The RPA.SAP library

The RPA.SAP library is based on the SapGuiLibrary.

Enable SAP Scripting Engine

SAP scripting must be enabled on the server and on the client.

SAP user with the required authorization should set the sapgui/user_scripting for the system. It is also recommended to set sapgui/user_scripting_per_user to allow scripting on per user basis and then set the authorization object S_SCR for defined users.


Set two parameters (sapgui/user_scripting and sapgui/user_scripting_per_user):

  • Execute saplogon.exe.
  • Log in to access SAP Easy Access.
  • From the transaction dropdown, select and run RZ11.
  • Enter sapgui/user_scripting as the parameter name.
  • Press the Display button.
  • Press the Change Parameter Value button.
  • Set New value to TRUE.
  • Click the save icon.
  • Add the sapgui/user_scripting_per_user parameter the same way and set it to TRUE.
  • Log out.
  • Log in.

SAP GUI Scripting Security Guide (PDF):

In some cases, it is not possible to enable SAP GUI Scripting for lack of a dedicated application server. This implies that users who are allowed to use SAP GUI Scripting work on the same server as others, so the support cannot be enabled for the server.

The problem can be solved by setting the rights to run SAP GUI Scripting per user. The new profile parameter sapgui/user_scripting_per_user allows the administrator then to enable SAP GUI Scripting support for specific users. Unless the administrator explicitly changes the value, this parameter is set to FALSE. If the profile parameter is set to TRUE the following happens:

  • On the login screen SAP GUI Scripting is available for every user.
  • After login, SAP GUI Scripting only remains available for those users that have the authorization for the Execute(16) action of the authorization object S_SCR in class BC_A.


After user scripting is enabled on the server, each user with S_SCR authorization can enable the scripting in the SAP GUI client:

  • Press the Customise Local Layout button.
  • Select Options.
  • Navigate to Accessibility & Scripting -> Scripting.
  • Check Enable scripting.
  • Uncheck both of the notification options if they are checked.
  • Click OK.

Opening a connection / Before running automation

Start the SAP Logon Pad application. Use the Connect To Session keyword to connect to the SAP Session.

After successful connection, use the Open Connection keyword to open a new connection from the SAP Logon Pad or Connect To Existing Connection to connect to a connection that is already open.

Here's an example for logging into SAP:

*** Settings *** Library RPA.Desktop WITH NAME Desktop Library RPA.Robocorp.Vault Library RPA.SAP WITH NAME SAP Library RPA.Windows WITH NAME Windows *** Keywords *** SAP Gui Login Desktop.Open Application ${EXE_PAD} Windows.Control Window ${TITLE_PAD} SAP.Connect To Session ${secrets}= Get Secret sap SAP.Open Connection ${secrets}[connection] SAP.Input Text ${FIELD_CLIENT} ${secrets}[client] SAP.Input Text ${FIELD_USER} ${secrets}[user] SAP.Input Password ${FIELD_PASSWORD} ${secrets}[password] SAP.Send Vkey 0
  • ${EXE_PAD}: An absolute filepath to saplgpad.exe
  • ${TITLE_PAD}: The window title of the saplgpad.exe application once it has started
  • ${FIELD_CLIENT}: A locator for the Client input field, wnd[0]/usr/txtRSYST-MANDT
  • ${FIELD_USER}: A locator for the User input field, wnd[0]/usr/txtRSYST-BNAME
  • ${FIELD_PASSWORD}: A locator for the Password input field, wnd[0]/usr/pwdRSYST-BCODE

Also check the SAP Logon & Login example by Robocorp community member RoboHeart!

Locating or specifying elements

Specify elements starting from the window ID, for example, wnd[0]/tbar[1]/btn[8]. In some cases, the SAP ID contains backslashes. Escape these backslashes by adding another backslash in front of them.

Check the SAP - MM01 - Create Material example by Robocorp community member RoboHeart!

Unofficial SAP inspector is called Scripting Tracker.

Please read section Security hint on Scripting Tracker's page before installing the application in any machine.

Screenshots (on error)

The RPA.SAP library has an option for automatic screenshots on error. This option is enabled by default. Use Disable Screenshots On Error to skip the screenshot functionality.

Alternatively, this option can be set when importing the library:

*** Settings *** Library RPA.SAP screenshots_on_error=True screenshot_directory=None

Example robots

Other SAP automation possibilites

  • The PyRFC Python package provides Python bindings for SAP NetWeaver RFC Library, for a comfortable way of calling ABAP modules from Python and Python modules from ABAP, via SAP Remote Function Call (RFC) protocol.
  • The pyodata Python package can be used to access SAP services that expose OData interface.
Last edit: September 11, 2023