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 the 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 may appear "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 misconfigured.
"Cannot communicate with SAP GUI Scripting interface. Click for more information."

sapError2.png


Root Cause

By default, the 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
  1. Select the “Accessibility & Scripting” option in the left panel
image.png
  1. Expand ‘Accessibility & Scripting’ and select “Scripting”
​​​​​​​image.png
  1. If the warning message is thrown, the option “Notify when a script attaches to SAP GUI” will be checked. To overcome the challenge, un-check the 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 GUI.

2 Likes