Reputation: 11
I am using VB script to launch SAP Logon application and successfully able to launch and login into SAP, but the issue, the next line of code is not getting executed until the application is closed.
Any approach how to achieve please suggest.
VB Script Code
[set WshShell = CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
Set proc = WshShell.Exec("C:\Program Files (x86)\SAP GUI_7.40_P10_LITE (VMware ThinApp)\saplogon.exe")
Do While proc.Status = 0
WScript.Sleep 100
Loop
Set SapGui = GetObject("SAPGUI")
Set Appl = SapGui.GetScriptingEngine
Set Connection = Appl.Openconnection("connectioname", True)
Set session = Connection.Children(0)
session.findById("wnd\[0\]/usr/txtRSYST-BNAME").Text = "username"
session.findById("wnd\[0\]/usr/pwdRSYST-BCODE").Text = "password"
session.findById("wnd\[0\]/usr/txtRSYST-LANGU").Text = "EN"
session.findById("wnd\[0\]").sendVKey 0][1]
Upvotes: 0
Views: 1684
Reputation: 31
Please refer https://botstore.automationanywhere.com/bot/sap-utilities/ , it is free. Just install it and you will be able to use the metabot.
I'd suggest not to use VBScript so extensively for SAP Automation. Metabots are highly compatible and reliable when it comes to SAP Automation. I can provide you SAP DLL (if you need), you can just import it and start using it. In this case, steps to Login to SAP would be as below.
Also, "the next line of code is not getting executes until the application is closed.", which line of code are you referring to exactly? Is it session.findById("wnd[0]").sendVKey 0][1]
Please try session.findById("wnd[0]").sendVKey [1] or session.findById("wnd[0]").sendVKey [0][1]
Upvotes: 1