
All SAP GUI Script developers have to use a tool to determine the IDs of the screen elements in order to make the script interact with these fields. There are the SAP GUI Script Recorder (part of SAP GUI), ScreenReader.exe provided by SAP (note 1441550 - SAP GUI scripting: Sample applications - SAP for Me) and Scripting Tracker by Stefan Schnell. The feature is also supported by SAP GUI Scripting, but you need to create a little script. Here is a simple script example and a demonstration video.
Short presentation of what does the script:
Create this file on your laptop (ScreenReader.vbs):
dim stopScript
dim SapGuiApp
dim sess
Set Wrp = WScript.CreateObject("SapROTWr.SapROTWrapper")
Set SapGui = Wrp.GetROTEntry ("SAPGUI")
If SapGui Is Nothing Then
MsgBox "SAP Logon/SAP GUI for Windows must be started first (manually)"
WScript.quit 0
End If
Set SapGuiApp = sapgui.GetScriptingEngine ' GuiApplication
set conn = SapGuiApp.Children(0)
set sess = conn.Children(0)
' or use InputBox to select one session? (see https://stackoverflow.com/questions/71624238/find-sap-gui-session-opened-for-given-sap-system)
set window = sess.ActiveWindow
' Connect the events to procedures
Call WScript.ConnectObject(sess,"sess_")
window.elementVisualizationMode = true ' this enables the connection of the Hit event to the connected method
' Endless loop until window is closed or user click a field > InputBox requests the end
stopScript = false
j = 1
Do While stopScript = false
j = j + 1
WScript.Sleep 200
Loop
Set sess = Nothing
Sub sess_Hit(Session, Component, InnerObject)
input = inputbox("Enter to continue the script, Cancel/Escape to leave.", , component.Id)
If input = "" Then
stopScript = True
End If
End Sub
Log manually into SAP GUI (user and password).
Run the VBS file (double-click it from Windows File Explorer).
Click on any field of the SAP GUI screen and a screen displays the field ID that you may copy.
Press Enter or click OK in this screen to continue with other fields, or press Escape or click Cancel to leave the script.
Currently, the script works only with the first session opened, but you may adapt it to find a session (see here how to loop at the opened sessions https://stackoverflow.com/questions/71624238/find-sap-gui-session-opened-for-given-sap-system)
Also, the script can work only if the SAP system is configured to allow SAP GUI Scripting and if you selected the Scripting component when you installed SAP GUI for Windows (Mac also).
References: some time ago, I had answered a question about the same topic, how to find the ID for FindById.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
24 | |
23 | |
9 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 | |
3 |