cancel
Showing results for 
Search instead for 
Did you mean: 

Error Message : Object required 'WScript'-

0 Kudos
1,491

Hello,

I cannot make WScript.sleep to work..

When I start to run the script, here is what I get : Object required: 'WScript' -

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]/tbar[0]/okcd").text = "QF01"
session.findById("wnd[0]").sendVKey 0

WScript.Sleep 500

session.findById("wnd[0]/usr/ctxtQALS-PRUEFLOS").text = "30000020135"
session.findById("wnd[0]/usr/ctxtQALS-PRUEFLOS").caretPosition = 11
session.findById("wnd[0]").sendVKey 0
Wscript.Sleep 300000
session.findById("wnd[0]/usr/ssubSUB_ITEM_OVERVIEW:SAPLQFFE:4100/tblSAPLQFFEITEM_OVERVIEW_SER/ctxtQFAAI-FEGRP[1,2]").setFocus
If session.findById("wnd[0]/usr/ssubSUB_ITEM_OVERVIEW:SAPLQFFE:4100/tblSAPLQFFEITEM_OVERVIEW_SER/ctxtQFAAI-FEGRP[1,2]").caretPosition = 0 Then
session.findById("wnd[0]/usr/ssubSUB_ITEM_OVERVIEW:SAPLQFFE:4100/tblSAPLQFFEITEM_OVERVIEW_SER/ctxtQFAAI-FEGRP[1,3]").setFocus
Wscript.Sleep 300000
session.findById("wnd[0]/usr/ssubSUB_ITEM_OVERVIEW:SAPLQFFE:4100/tblSAPLQFFEITEM_OVERVIEW_SER/ctxtQFAAI-FEGRP[1,3]").text = "qfdc"
End If

Former Member
0 Kudos

Thank you for visiting SAP Community to get answers to your questions. Since you're new in asking questions here, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers (if you haven't already), as it provides tips for preparing questions that draw responses from our members.

Should you wish, you can revise your question now by selecting Actions, then Edit.

Finally, if you're hoping to connect with readers, please consider adding a picture to your profile. Here's how you do it: https://www.youtube.com/watch?v=F5JdUbyjfMA&list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS By personalizing your profile with a photo of you, you encourage readers to respond.

Best regards,

SAP Community moderator

Sandra_Rossi
Active Contributor
0 Kudos

Are you sure it fails at WScript.Sleep 500 ?

0 Kudos

Im sure it fails at WScript.Sleep 500 because when I remove it then the script runs really well (no message error)

0 Kudos

I am also facing the Same issue . Can anyone please help?

Accepted Solutions (0)

Answers (2)

Answers (2)

FrankKrauseGUI
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Inas,

such commands can only work if the script is started via the scripting host wscript.exe / cscript.exe.

The standard script header created by SAP GUI contains this:
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End If

You can easily do similar checks in your script.

However, if you want a sleep to work via wscript, then you need to run the script as mentioned above.
For example:
- Open command prompt (must be running with the same permissions as SAP GUI!)
- wscript.exe <scriptfile>

And regarding the sleep(300000). Do you really want to wait that long?

Best regards,
Frank

mbov
Explorer
0 Kudos

Why are you using WScript.Sleep? Usually, the script will wait on it's own until an input is made. Just scrap WScript completely.

If you need to sleep a certain time (seems like you want to wait 5 minutes here), use the specific language equivalent. E.g. Thread.Sleep in C#