cancel
Showing results for 
Search instead for 
Did you mean: 

Can not make Wscript.Sleep work in my script.

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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 Kudos

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 Kudos

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

0 Kudos

Hello,

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

Wscript.Sleep 60000

Is there a solution please ?

Former Member
0 Kudos

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

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

Try to run your script with wscript.exe

eg> wscript.exe c:\test.vbs

Check you are getting same error now ?