on ‎2022 Oct 25 10:39 PM
Dear Expert,
We use python call SAP GUI scripting to do some RPA work, and it worked very well in majority associations, but when we use python to bind event of application , there have a problem and we can't solve by ourselves, could you help us to determine is there any bug in SAP GUI scripting with python?
The bellow code we tested in VBS and it run well.
Dim objSapGui
Set objSapGui = GetObject("SAPGUI")
Dim objScriptingEngine
Set objScriptingEngine = objSapGui.GetScriptingEngine
WScript.ConnectObject objScriptingEngine, "Engine_"
Dim Waiting
Waiting = 1
Do While (Waiting = 1)
WScript.Sleep(100)
Loop
Set objScriptingEngine = Nothing
Set objSapGui = Nothing
Sub Engine_CreateSession(ByVal Session)
Dim result
result = MsgBox("Session created", vbOKCancel)
If result = vbCancel then
Waiting = 0
End If
End Sub
But when we ran bellow code in python, there turned up with an error: AssertionError
import win32com.client
class Events:
def __init__(self):
pass
appl = win32com.client.GetObject("SAPGUI").GetScriptingEngine
event = win32com.client.WithEvents(appl, Events)
Looking forwar to your reply
Thanks!
Request clarification before answering.
Hello customer,
Thank you for reaching out to SAP Community.
Please refer to the technical article available in the following link:
https://blogs.sap.com/2017/09/19/how-to-use-sap-gui-scripting-inside-python-programming-language/
The recorded VBScript code can use almost always unchanged inside Python, but sometimes it is necessary to set some brackets.
Try to use the sample code outlined in the blog.
Best regards,
SAP Support
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 5 | |
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.