cancel
Showing results for 
Search instead for 
Did you mean: 

ME22N - problem with automatic delivery date update via script (sap,excel,vba).

Former Member
0 Kudos

Good morning everyone.

I have a problem when it comes to the automatic PO delivery date update by script ran from excel (I get a report with 200 of deliveries to be updated, so doing it manually takes too much time).

What I try to do via script is basically explained in the picture below:

I present the code for this action below:

Dim i As Integer


i = 1


Do Until i > 23
i = i + 1


session.findById("wnd[0]").maximize
session.findById("wnd[0]").sendVKey 0
On Error GoTo 0
On Error Resume Next
session.findById("wnd[0]/tbar[1]/btn[17]").press
On Error GoTo 0
On Error Resume Next
Set Container = session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015")
On Error GoTo 0
On Error Resume Next
session.findById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/ctxtMEPO_SELECT-EBELN").Text = Cells(i, 1)
On Error GoTo 0
On Error Resume Next
session.findById("wnd[1]").sendVKey 0


On Error GoTo 0
On Error Resume Next
session.findById("wnd[1]/usr/btnSPOP-OPTION1").press
On Error GoTo 0
On Error Resume Next
Set Container = session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0016")
On Error GoTo 0
On Error Resume Next
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0016/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/btnSCHNELLAEND").press
On Error GoTo 0
On Error Resume Next
Set Container = session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010")
On Error GoTo 0
On Error Resume Next
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/btnSCHNELLAEND").press
On Error GoTo 0
On Error Resume Next
session.findById("wnd[1]/usr/btnSPOP-OPTION1").press
On Error GoTo 0
On Error Resume Next
session.findById("wnd[1]/usr/btnSPOP-VAROPTION1").press
On Error GoTo 0
On Error Resume Next
Set Container = session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0051")
On Error GoTo 0
On Error Resume Next
session.findById("wnd[1]/usr/subSUB1:SAPLMEGUI:0051/subSUB1:SAPLMMDV:0010/txtMEGUI_MASSCH_ALLOWED_FIELDS-EEIND").Text = Cells(i, 2)
On Error GoTo 0
On Error Resume Next
Set Container = session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0051")
On Error GoTo 0
On Error Resume Next
session.findById("wnd[1]/usr/subSUB1:SAPLMEGUI:0051/subSUB1:SAPLMMDV:0010/txtMEGUI_MASSCH_ALLOWED_FIELDS-EEIND").caretPosition = 5
On Error GoTo 0
On Error Resume Next
session.findById("wnd[1]/tbar[0]/btn[8]").press
On Error GoTo 0
On Error Resume Next


Loop

Let me explain where ist the problem. I tried this code successfully on a few POs however, as soon as "SAPLMEGUI:" number changes (I believe it is done randomly, because on screen nothing changes at all), the script malfunction by either not changing PO delivery date or not opening a new PO (and changes the date in the previous PO, to the wrong one).

Here the question to you dear readers is how to overcome this problem?


I have had already googled this topic many times, however, I could not solve my problem (maybe I simply do not understand, the explanation). That is why I create a new one. I am currently learning VBA and Sap Scripts, so if you were so kind to answer, please try to make an easy explanation as possible.

Kind Regards,

Micha?.

Accepted Solutions (0)

Answers (1)

Answers (1)

script_man
Active Contributor
0 Kudos

Hi Michal,

to see where the error happens, you have to disable all commands with "on error".

Regards,

ScriptMan