1

I made a script to open SAP GUI with Python.

from win32com.client import Dispatch
#reference sapfewse.ocx like a dll file with makepy()
app = win32com.client.Dispatch("Sapgui.ScriptingCtrl.1")
conn = app.OpenConnection("System_Name", True)
ses = conn.Children

I am able to open the SAP GUI Scripting window with the code but, I think there is a problem with the Children(0) part as it does not allow me to use the ses.FindByID to access the ID tags.

Any tips?

2
  • import sys from win32com.client import makepy Commented Apr 18, 2017 at 12:44
  • sys.argv = ["makepy", r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui\sapfewse.ocx"] makepy.main() Commented Apr 18, 2017 at 12:44

1 Answer 1

1

I believe for some reason makepy doesn't resolve the inheritance of the classes in the SAP dll correctly. You have to make sure you clean out your gencache of any files generated for the SAP dll, then dispatch the Sapgui.ScriptingCtrl.1 dynamically.

import win32com.client as win32

app = win32.dynamic.Dispatch("Sapgui.ScriptingCtrl.1")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.