作为SAP MM的一名官员,我想编写一个应用程序来完成一些重复的工作。但是当我录制SAP Gui Script时,我无法在Python中成功运行它。我是否使用了错误的模块或者我的代码有问题?
import win32com.client
import sys
def SAP_OP():
excelPath = r'#'
SapGuiAuto = win32com.client.GetObject("SAPGUI")
if not type(SapGuiAuto) == win32com.client.CDispatch:
return
application = SapGuiAuto.GetScriptingEngine
if not type(application) == win32com.client.CDispatch:
SapGuiAuto = None
return
connection = application.Children(0)
if not type(connection) == win32com.client.CDispatch:
application = None
SapGuiAuto = None
return
session = connection.Children(0)
if not type(session) == win32com.client.CDispatch:
connection = None
application = None
SapGuiAuto = None
return
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").text = "/nMM03"
session.findById("wnd[0]").sendVKey(0)
session.findById("wnd[0]/usr/ctxtS_VKORG-LOW").text = "#"
session.findById("wnd[0]/usr/ctxtS_VTWEG-LOW").text = "#"
session.findById("wnd[0]/usr/ctxtP_EKORG").text = …Run Code Online (Sandbox Code Playgroud) python-3.x ×1