Skip to Content
0

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

Aug 03, 2017 at 08:57 AM

219

avatar image
Former Member

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?.

sap-forum.png (73.6 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Script Man Aug 04, 2017 at 09:47 AM
0

Hi Michal,

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

Regards,

ScriptMan

Share
10 |10000 characters needed characters left characters exceeded