Skip to Content

Stop script in VA02 at a specific line item?

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Dec 07, 2011 at 04:41 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.