Skip to Content
author's profile photo Former Member
Former Member

Use empty line


I am new in scripting.

I need to automate some actions using vbs, For example I want to add some materials using CN22.

The problem is that there are different number of materials already existing in the different NTWs and I need the new material to be inserted in the first empty line.

Please help me if you know any way to solve this using vbs.

'For example: In this case there is one material existing already and empty line used for new material is [1]

'but how to choose line [2 or other] if different number of materials already exist?

session.findById("wnd[0]/usr/tabsTABSTRIP_2700/tabpALLE/ssubSUBSCR_2000:SAPLCOMK:2701/tblSAPLCOMKTCTRL_2701/ctxtRESBD-MATNR[1,1]").text = "Material"

Thank you!


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 25, 2012 at 11:30 AM

    Hi again,

    Let me reformulate the question.

    How should it look like script which checks field by field in SAP if it is already filled and if it is not to fill required information which is stored in Excel file?

    I suppose it should be something like bellow.

    Please help to find the solution.


    Do Until session.findById("wnd[0]/usr/tabsTABSTRIP_2700/tabpALLE/ssubSUBSCR_2000:SAPLCOMK:2701/tblSAPLCOMKTCTRL_2701/ctxtRESBD-MATNR[1,x]").text = " "



    session.findById("wnd[0]/usr/tabsTABSTRIP_2700/tabpALLE/ssubSUBSCR_2000:SAPLCOMK:2701/tblSAPLCOMKTCTRL_2701/ctxtRESBD-MATNR[1,x]").text = sht.cells(i,2).Value

    Thank you !


    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Guero,

      If you now know where the error occurs, you can try the following:

      For i= 11 to 14

      x= i -11

      if x = 0 then

      session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-BANFN[13," & cstr(x) & "]").text = sht.cells(i,15).Value 'Purchase requisition

      session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-BNFPO[14," & cstr(x) & "]").text = sht.cells(i,16).Value 'Requisition item


      session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-BANFN[13," & cstr(x) & "]").text = sht.cells(i,15).Value 'Purchase requisition

      session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-BNFPO[14," & cstr(x) & "]").text = sht.cells(i,16).Value 'Requisition item

      end if

      session.findById("wnd[0]").sendVKey 0


      It assumes that all other parameters work like the second parameter. Otherwise, one would have determine the difference for the 3rd, 4th, 5th .. parameter.



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.