on 2012 Mar 08 12:35 PM
Dear EXperts,
Newbie here.
I was able to record something (picking progress in TC LT45) and thus generate a VBS file.
Now, running this script is doing what it should do, except for the timing: It runs way too fast and therefore I am searching for adding some command/code to pause.
I found examples like Application.Wait("0:00:1000") but SAP does not like that.
See 'my' code below.
Any answer will be appreciated.
Thanks, Nick
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]").resizeWorkingPane 263,47,false
session.findById("wnd[0]").sendVKey 8
Application.Wait("0:00:1000")
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]").sendVKey 8
Application.Wait("0:00:5000")
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]").sendVKey 8
Application.Wait("0:00:1000")
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]").sendVKey 3
Edited by: N. Lagace on Mar 8, 2012 1:37 PM
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
From a programming standpoint using sleep states and wait states is not optimal, it makes the script unreliable and take longer to run than it strictly needs to.
I will usually reference fields directly by ID and then write directly to them. IE:
session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL_255-SLOW_I[1,0]").text = "CC*"
or a simpler reference:
session.findById("wnd[0]/usr/txtMAX_SEL").text = "1000000 "
wnd is the window, then there is a simple hierarchy, so wnd(window number]/[part of window]/[field name]).[text] = [in quotes, the text that should go into the field, or a variable/parameter (no quotes for those)]
You can use the script recording feature to find out what the individual fields references are, or you can use GuiXT, navigate to a field, and note the field name in the GuiXT info box.
Using direct references like this, the system will automatically wait until a field entry is completed before moving to the next one.
I feel this is a more elegant solution than programing wait periods into the script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.