sap脚本运行_如何使用Python脚本运行SAP?
目前,我正在研究如何在stackoverflow的帮助下用python启动SAP脚本,但显然我的SAP没有打开连接页面,即输入用户名和密码的页面。我相信DCG210是我的连接名,下面的图片显示了我运行python代码后的着陆位置。
另外,如果有人有学习用Python编写SAP脚本的链接,我将不胜感激。谢谢您!在import win32com.client
import sys
import subprocess
import time
# This function will Login to SAP from the SAP Logon window
def saplogin():
try:
path = r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe"
subprocess.Popen(path)
time.sleep(10)
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.OpenConnection("DCG210", True)
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]/usr/txtRSYST-BNAME").text = "USERNAME"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "PASSWORD"
session.findById("wnd[0]").sendVKey(0)
except:
print(sys.exc_info()[0])
finally:
session = None
connection = None
application = None
SapGuiAuto = None
saplogin()
文章来自于网络,如果侵犯了您的权益,请联系站长删除!