on 01-10-2008 8:17 PM
Need help understanding why this errors out at Wscript.Sleep 60000. I need the script to wait until the transaction executes before going to the next step in the script. I am trying to use the CS12 transaction to export the BOM for several different Materials. Thanks for your help.
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]/usr/ctxtRC29L-MATNR").text = "firstMaterial"
session.findById("wnd[0]/usr/ctxtRC29L-MATNR").caretPosition = 10
session.findById("wnd[0]").sendVKey 8
Wscript.Sleep 60000
session.findById("wnd[0]").sendVKey 45
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "filename.txt"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 7
session.findById("wnd[1]").sendVKey 7
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]/usr/ctxtRC29L-MATNR").text = "nextMaterial"
session.findById("wnd[0]/usr/ctxtRC29L-MATNR").caretPosition = 13
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]").sendVKey 45
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "filename.txt"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 7
session.findById("wnd[1]").sendVKey 7
session.findById("wnd[0]").sendVKey 3
Wscript.Sleep 60000 is right statement to do Wait functionaliy. It works properly in VBScript, Let me know whether you are not able to wait the program or it is not working ? any errors ? because i could not understand how its now working ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In my experience, you don't need the Sleep instructions. I tested the code you had on my system and it appeared to work fine - at least the Sleep instruction. I did notice, however, that I was being prompted for the Plant and BOM Application as well. So it could be that other system messages need to be trapped and handled if they appear (such as a hard error message in the status bar).
Hi there,
You have a question and need help by the community? Instead of posting into an old question thread, it is more helpful for you, if you create your own question. Here is how to get started:
That's it. Thank you!
Best regards,
Your SAP Community moderator
Hi, I am not familiar with your transaction however, I usually grab the window title and compare or I check for the existance of something else unique and process based on that.
Example: check for first instance of SAP. If first instance we get a SAP Easy Access screen after login, otherwise a make some selection screen to cancel login or create another instance etc...
if session.findById("wnd[0]/titl").text="SAP Easy Access" then
else
session.findById("wnd[1]/usr/rad[1]").select
session.findById("wnd[1]/usr/rad[1]").setFocus
session.findById("wnd[1]").sendVKey 0
end if
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try to run your script with wscript.exe
eg> wscript.exe c:\test.vbs
Check you are getting same error now ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.