cancel
Showing results for 
Search instead for 
Did you mean: 

Stop script in VA02 at a specific line item?

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

script_man
Active Contributor
0 Kudos

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