Skip to Content

Loop key in VBS script recording - Sap Gui

Hi,

I have been record a Script to unlock delivery item for purchase order (PO) (.select=false) like image, but more PO different number item so i need your help.

This script works fine, but I need it to loop to the next Key and then continue looping until there are no more key.

REM HERE MY RECORD VBS*********************************

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB1:SAPLMEGUI:6000/cmbDYN_6000-LIST").setFocus

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB1:SAPLMEGUI:6000/cmbDYN_6000-LIST").key = " 1"

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT6/ssubTABSTRIPCONTROL1SUB:SAPLMEGUI:1313/chkMEPO1313-ELIKZ").selected = false

REM END MY RECORD VBS***************************

I would really appreciate it if someone could help me.

Many Thanks

Truong from Viet Nam

1.png (70.0 kB)
2.png (33.5 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Jan 29 at 10:54 AM

    No idea how many spaces it needs to be, but it could be work e.g. also like that.

    i = 0
    do 
    i = i+1
    
    session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB1:SAPLMEGUI:6000/cmbDYN_6000-LIST").setFocus
    
    on error resume next
    session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB1:SAPLMEGUI:6000/cmbDYN_6000-LIST").key= right("   " & cstr(i), 4)
    
    if err.number <> 0 then exit do
    on error goto 0
    
    session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT6/ssubTABSTRIPCONTROL1SUB:SAPLMEGUI:1313/chkMEPO1313-ELIKZ").selected
    = false
    
    Loop
    
    Add comment
    10|10000 characters needed characters exceeded

  • Jan 29 at 08:00 AM

    Hi Mr Truong,

    You could try the following:

    i = 0
    do
    i = i + 1
    session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB1:SAPLMEGUI:6000/cmbDYN_6000-LIST").setFocus
    on error resume next
    session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB1:SAPLMEGUI:6000/cmbDYN_6000-LIST").key = " " & cstr(i)
    if err.number <> 0 then exit do
    on error goto 0
    session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT6/ssubTABSTRIPCONTROL1SUB:SAPLMEGUI:1313/chkMEPO1313-ELIKZ").selected = false
    loop
    
    

    Regards,

    ScriptMan

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 30 at 07:11 AM

    Thank you very much ScriptMan.

    Your script is really usefull with me.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 29 at 08:59 AM

    Thanks for your reply, ScriptMan

    Your script is working really smooth but unfortunately your script just working "key 1" to "key 9", "key 10" to end not working

    Can you help me?

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 29 at 10:00 AM

    Hi ScriptMan,

    base on your script, i code one more line same your script but i change some thing.

    i = 0
    do until i > 10
    i = i+1
    
    session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB1:SAPLMEGUI:6000/cmbDYN_6000-LIST").setFocus
    
    on error resume next
    session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB1:SAPLMEGUI:6000/cmbDYN_6000-LIST").key= "   " & cstr(i)
    
    if err.number <> 0 then exit do
    on error goto 0
    
    session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT6/ssubTABSTRIPCONTROL1SUB:SAPLMEGUI:1313/chkMEPO1313-ELIKZ").selected
    = false
    
    loop
    REM ***********************************
    
    i = 9
    do 
    i = i+1
    
    session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB1:SAPLMEGUI:6000/cmbDYN_6000-LIST").setFocus
    
    on error resume next
    
    session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB1:SAPLMEGUI:6000/cmbDYN_6000-LIST").key= "  " & cstr(i)
    
    if err.number <> 0 then exit do
    on error goto 0
    
    session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT6/ssubTABSTRIPCONTROL1SUB:SAPLMEGUI:1313/chkMEPO1313-ELIKZ").selected
    = false
    
    loop
    
    Add comment
    10|10000 characters needed characters exceeded