A Script Is Trying To Access SAP GUI

How to fix an issue "A script is trying to access SAP GUI" while inspecting an element in a SAP application or executing a process that automates SAP via Robot?

Issue Description: A pop up with a message "A script is trying to access SAP GUI" is prompted by SAP whenever an external script\program tries to access a GUI element. In some cases, a different message "A script is trying to attach to GUI"

Starting with the UiPath.UIAutomation.Activities package v 22.4.4, the activities will also return an error message when interacting with SAP if the scripting is miss-configured.
"Cannot communicate with SAP GUI Scripting interface. Click for more information".

sapError2.png


Root Cause:
By default, SAP application notifies the user that some program is trying to access the SAP GUI application. This is to prevent a program from making any changes in the SAP without a user's consent.


Resolution:
These settings are configurable and can be disabled through SAP Accessibility and scripting settings,

  1. Launch SAP GUI application manually.
  2. Navigate to ‘Options’ as below or press “Alt+F12” and click ‘Options'.image.png
  3. Select the “Accessibility & Scripting” option in the left paneimage.png
  4. Expand ‘Accessibility & Scripting’ and select “Scripting”image.png
  5. If the warning message is thrown, the option “Notify when a script attaches to SAP GUI” would be checked. To overcome the challenge, un-check following options:
    1. Notify when a script attaches to SAP GUI
    2. Notify when a script opens a connection. Click “Apply” followed by “OK”.

Note: The above screen may vary for different versions of SAP.

2 Likes