on 12-07-2011 3:33 PM
Hello,
I got a script which are setting RREC on sales order line items that is not working properly, I want it to stop and save when it has set RREC to last line item, item 100.
I figured it should be able to identify when it is positioned on line item 100 through this part of the code, but it loops forever instead.
This is what I got now:
SONumber = ActiveCell.Offset(0, 1).Value
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").Text = SONumber
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").caretPosition = 7
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[0]/tbar[0]/btn[83]").press
Do Until session.findById("usr/subSUBSCREEN_HEADER:SAPMV45A:4013/txtVBAP-POSNR").Text = 100 '<-- This is the field in SAP that is displaying the current line item. I want it to set RREC to this item and then save, but it just continues to loop instead.
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/ctxtRV45A-MABNR[1,12]").SetFocus
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/ctxtRV45A-MABNR[1,12]").caretPosition = 0
session.findById("wnd[0]/mbar/menu[2]/menu[2]/menu[13]").Select
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\12/ssubSUBSCREEN_BODY:SAPMV45A:4456/btnBT_PSTC").press
session.findById("wnd[0]/usr/tabsTABSTRIP_0300/tabpANWS/ssubSUBSCREEN:SAPLBSVA:0302/sub:SAPLBSVA:0302[2]/chkJ_STMAINT-ANWSO[0,0]").Selected = True '<-- RREC checkbox
session.findById("wnd[0]/usr/tabsTABSTRIP_0300/tabpANWS/ssubSUBSCREEN:SAPLBSVA:0302/sub:SAPLBSVA:0302[2]/chkJ_STMAINT-ANWSO[0,0]").SetFocus
session.findById("wnd[0]/tbar[0]/btn[3]").press '<-- Back
session.findById("wnd[0]/tbar[1]/btn[18]").press '<-- Next item
Loop
session.findById("wnd[0]/tbar[0]/btn[11]").press '<--- Save
Anyone have an idea of how to get it to stop here?
Some line items does not have a RREC-button either and even whole sales orders. Any solution on how to skip those?
Thanks,
Mattias
Hi Mattias,
You could try the following:
Do Until session.findById("usr/subSUBSCREEN_HEADER:SAPMV45A:4013/txtVBAP-POSNR").Text = "100"
If something does not exist, you can skip it as follows:
on error resume next
'Here's a command that does not exist
if err.number > 0 or err.number < 0 then
. . .
end if
on error goto 0
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.