on 07-08-2011 8:15 PM
Hi All,
I'm very new to SAP GUI scripting and am not a programmer. I need to create several test postings in SAP. I was able to record a script that makes the posting and it works great. However, i can only run it one at time.
I found another thread on how to creat a shell script, then call the script that does the posting. I was also able to figure out how to make it loop a certain numbe of times. This works OK when i have the GUI setting to notify me when a script tries to run on the system; but when I turn this off it looks like it's trying to run the second iteration before the first one is done.
Is there a simple command or way to make each iteration wait for the previous one to finish, before starting a new iteration?
Any help would be greatly appreciated. The two scripts are pasted below for reference.
Thanks
Kory
Shell script:
set Wshell = CreateObject("WScript.Shell")
dim n
n = 1
do while (n < 5)
wshell.run "wscript.exe ""D:\Documents and Settings\e436962\My Documents\SAP Scripting\DAR.vbs"
n = n + 1
loop
DAR script:
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/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selectedNode = "F00003"
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00003"
session.findById("wnd[0]/usr/cntlCONTAINER_MAIN/shellcont/shell").selectItem " 22","Column3"
session.findById("wnd[0]/usr/cntlCONTAINER_MAIN/shellcont/shell").ensureVisibleHorizontalItem " 22","Column3"
session.findById("wnd[0]/usr/cntlCONTAINER_MAIN/shellcont/shell").clickLink " 22","Column3"
session.findById("wnd[0]/usr/tabsTABSTRIP_MYTAB/tabpPUSH1/ssub%_SUBSCREEN_MYTAB:/PMPAY/PRE_DAR:0100/ctxtP_KUNNR").text = "300043"
session.findById("wnd[0]/usr/tabsTABSTRIP_MYTAB/tabpPUSH1/ssub%_SUBSCREEN_MYTAB:/PMPAY/PRE_DAR:0100/ctxtP_BUKRS").text = "1000"
session.findById("wnd[0]/usr/tabsTABSTRIP_MYTAB/tabpPUSH1/ssub%_SUBSCREEN_MYTAB:/PMPAY/PRE_DAR:0100/ctxtP_WAERS").text = "USD"
session.findById("wnd[0]/usr/tabsTABSTRIP_MYTAB/tabpPUSH1/ssub%_SUBSCREEN_MYTAB:/PMPAY/PRE_DAR:0100/ctxtP_WAERS").setFocus
session.findById("wnd[0]/usr/tabsTABSTRIP_MYTAB/tabpPUSH1/ssub%_SUBSCREEN_MYTAB:/PMPAY/PRE_DAR:0100/ctxtP_WAERS").caretPosition = 3
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTABSTRIP_MYTAB/tabpPUSH2").select
session.findById("wnd[0]/usr/tabsTABSTRIP_MYTAB/tabpPUSH2/ssub%_SUBSCREEN_MYTAB:/PMPAY/PRE_DAR:0200/txtP_AUTWV").text = "100.00"
session.findById("wnd[0]/usr/tabsTABSTRIP_MYTAB/tabpPUSH2/ssub%_SUBSCREEN_MYTAB:/PMPAY/PRE_DAR:0200/ctxtP_CCINS").text = "visa"
session.findById("wnd[0]/usr/tabsTABSTRIP_MYTAB/tabpPUSH2/ssub%_SUBSCREEN_MYTAB:/PMPAY/PRE_DAR:0200/ctxtP_CCNUM").text = "-E803-4448-GHPB200000000K"
session.findById("wnd[0]/usr/tabsTABSTRIP_MYTAB/tabpPUSH2/ssub%_SUBSCREEN_MYTAB:/PMPAY/PRE_DAR:0200/txtP_DATBI").text = "12/2012"
session.findById("wnd[0]/usr/tabsTABSTRIP_MYTAB/tabpPUSH2/ssub%_SUBSCREEN_MYTAB:/PMPAY/PRE_DAR:0200/txtP_DATBI").setFocus
session.findById("wnd[0]/usr/tabsTABSTRIP_MYTAB/tabpPUSH2/ssub%_SUBSCREEN_MYTAB:/PMPAY/PRE_DAR:0200/txtP_DATBI").caretPosition = 7
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTABSTRIP_MYTAB/tabpPUSH2/ssub%_SUBSCREEN_MYTAB:/PMPAY/PRE_DAR:0200/btnPB_AUTH").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
Hi Kory,
The simple command is already wshel.run and its parameters.
. . .
wshell.run chr(34) & "D:\Documents and Settings\e436962\My Documents\SAP Scripting\DAR.vbs" & chr(34) , 1, true
. . .
Please look at this link also: http://msdn.microsoft.com/en-us/library/d5fk67ky(v=vs.85).aspx
Regards,
ScriptMan
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.