on ‎2008 Jan 10 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
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.