on 2020 Dec 15 5:52 PM
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
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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#
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.