cancel
Showing results for 
Search instead for 
Did you mean: 

GUI Scripting ME22n Change Delivery Date in "Position"

former_member870569
Discoverer
0 Kudos

Hi,

I have problems selecting the cell of the confirmed delivery date (in German "Lieferdatum") in ME22n via script. I recorded and tried my script in the Q-system (my company doesn't allow recordings in the P-System), and it works without any problem. In the P-System, an error pops up as soon as the script tries to select the cell (I highlighted the cell yellow).

Here is the relevant part of my code:

'open ME22n and the specific order
objSess.FindById("wnd[0]/tbar[0]/okcd").Text = "/NME22N"
objSess.FindById("wnd[0]").SendVKey 0
objSess.FindById("wnd[0]").SendVKey 17
' use the PO number from an excel file
objSess.FindById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/ctxtMEPO_SELECT-EBELN").Text = Worksheets("Script").Cells(currentline, 1).Value 
objSess.FindById("wnd[1]").SendVKey 0

'starting to loop through the rows
Dim i As Integer
i = 0
Do
        Dim Datum As Date
        Dim datum_alt As Date

' !! THE FOLLOWING LINE CAUSING AN ERROR !!
        Datum = objSess.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0020/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT17/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB2:SAPLMEGUI:1332/subSUB0:SAPLEINB:0300/tblSAPLEINBTC_0300/ctxtRM06E-EEIND[2," & Int(i) & "]").Text
        datum_alt = Worksheets("Script").Cells(currentline, 4).Text
        Dim menge As Integer
        Dim menge_alt As Integer
'!! SAME HERE !!
        menge = objSess.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0020/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT17/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB2:SAPLMEGUI:1332/subSUB0:SAPLEINB:0300/tblSAPLEINBTC_0300/txtEKES-MENGE[4," & Int(i) & "]").Text
        menge_alt = Worksheets("Script").Cells(currentline, 5).Text

        If datum_alt = Datum Then
                Worksheets("Script").Cells(currentline, 6).Value = "JA"
                Else: Worksheets("Script").Cells(currentline, 6).Value = Datum
        End If
        If menge = menge_alt Then
            Worksheets("Script").Cells(currentline, 7).Value = "JA"
            Else: Worksheets("Script").Cells(currentline, 7).Value = menge
        End If
i = i + 1
Loop Until Worksheets("Script").Cells(currentline, 6).Value = "JA" And Worksheets("Script").Cells(currentline, 7).Value = "JA" Or objSess.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0020/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT17/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB2:SAPLMEGUI:1332/subSUB0:SAPLEINB:0300/tblSAPLEINBTC_0300/ctxtRM06E-EEIND[2," & Int(i) & "]").Text = ""

In general, the following code does not work:

objSess.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0020/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT17/ssubTABSTRIPCONTROL1SUB:SAPLMEVIEWS:1101/subSUB2:SAPLMEGUI:1332/subSUB0:SAPLEINB:0300/tblSAPLEINBTC_0300/ctxtRM06E-EEIND[2,0]").SetFocus

Does anybody have any idea what could be wrong? How could the code work in the Q system but not in the P system?

Thank you very much! With best regards, Simon

View Entire Topic
stefan_schnell
Active Contributor
0 Kudos

Hello simon.graf,

your ID contains a lot of screen numbers, e.g. subSUB0:SAPLMEGUI:0020. Often these numbers differ in different systems, in your case the Q- and the P-system. To find out if this is the case you can call the method session.GetObjectTree in both systems and compare them. The method is available with the SAP GUI for Windows 7.70 PL 3. It is described in detail in the help and in the context of VBA it should not be difficult to extract the content. Let us know your results.

Best regards
Stefan

former_member870569
Discoverer

Hello Stefan,
thank you very much for the input! It was indeed subSUB0:SAPLMEGUI:0020, in the P-System 0019 is used.

Kind regards
Simon