-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathSAPGUISCRIPT logon
49 lines (47 loc) · 2.04 KB
/
SAPGUISCRIPT logon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#work for logon by user and password, not work for PKI logon
set WshShell = CreateObject("WScript.Shell")
Set proc = WshShell.Exec("C:\Program Files\SAP\FrontEnd\SAPgui\saplogon.exe")
Do While proc.Status = 0
WScript.Sleep 100
Loop
Set SapGui = GetObject("SAPGUI")
Set Appl = SapGui.GetScriptingEngine
Set Connection = Appl.Openconnection("Test SAP", True)
Set session = Connection.Children(0)
session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "xxx"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "xxxxx"
session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "E"
session.findById("wnd[0]").sendVKey 0
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").text = "/nMM03"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/okcd").text = "/nSE16"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").text = "MARD"
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").caretPosition = 4
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtI2-LOW").text = "PLF6"
session.findById("wnd[0]/usr/ctxtI2-LOW").setFocus
session.findById("wnd[0]/usr/ctxtI2-LOW").caretPosition = 4
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/mbar/menu[6]/menu[5]/menu[2]/menu[2]").select
session.findById("wnd[1]/usr/sub/1/rad[1,0]").select
session.findById("wnd[1]/usr/sub/1/rad[1,0]").setFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/ctxtRLGRAP-FILENAME").text = "C:\MARD.xls"
session.findById("wnd[1]/usr/ctxtRLGRAP-FILENAME").caretPosition = 11
session.findById("wnd[1]").sendVKey 0