cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Can not make Wscript.Sleep work in my script.

Former Member
0 Likes
2,931

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

View Entire Topic
Former Member
0 Likes

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 ?

Former Member
0 Likes

I am getting the error, Object required: 'WScript'- when I run the script. Maybe I do not even need Wscript.Sleep in the script, it seems to run fine without it but I was thinking I needed the script to wait for the requested data to return before going to the next statement in the script.

bryan_lanning2
Explorer
0 Likes

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).

Former Member
0 Likes

Hello,

I have the same error.. Object required: 'WScript' when I use this :

Wscript.Sleep 60000

Is there a solution please ?

Former Member
0 Likes

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:

  1. Learn about asking and answering questions in SAP Community with this tutorial: https://developers.sap.com/tutorials/community-qa.html
  2. Ask your detailed question here: https://answers.sap.com/questions/ask.html
  3. Wait for a response.

That's it. Thank you!

Best regards,

Your SAP Community moderator