Skip to Content
0
Nov 22, 2011 at 09:07 AM

Looping a SAPscript

116 Views

Hello!

I'm using a Excel macro with a connection to SAP with the purpose to, in VA02, set system status RREC on sales order items. As the amount of item lines are unknown in each case, I want a macro that goes backwards from the last item and sets the status from the last item all the way up to item 100 which is always the first line item.

This is the idea,

It enters transaction va02

Enters the sales order

Click the button that scrolls the list all the way down

Up arrow to get to the actual last item

Goto, Item, Status

Object status

Check RREC status

Back

And now I want to loop it so it does this until the last (which is the actual first, line item 100).

session.findById("wnd[0]").resizeWorkingPane 150,25,false
session.findById("wnd[0]/tbar[0]/okcd").text = "va02"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").text = "3405192"
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
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,3]").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,3]").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
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
session.findById("wnd[0]/tbar[1]/btn[18]").press
session.findById("wnd[0]/tbar[0]/btn[11]").press

I don't know if this loop is supposed to be in the Excel code or in this SAPscript code.

Anyone?

BR Mattias