cancel
Showing results for 
Search instead for 
Did you mean: 

VBS & Enjoy transactions

Former Member
0 Kudos

Hi Guys,

I have a question regarding so called "enjoy transactions".

Is there any way to automate this type of transactions using vbscript?

In my case I'm trying to automate PO creation using ME21N(ME21 is not applacable) and the problem is always changing SAPLMEGUI:0010

For example below SAPLMEGUI: is 0013

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-BANFN[13," & cstr(x) & "]")

I've found several threads for this issue in SCN but there are not solutions for them.

Please advise if vbs is applicable for these transactions.

If yes please provide an example.

Thank you in advance!    

Regards

Guero

Accepted Solutions (1)

Accepted Solutions (1)

holger_khn
Contributor
0 Kudos

Hello. Just check if an field is changeable:

If session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-BANFN[13," & cstr(x) & "]").Changeable = True Then strScreen = "0013"

If session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-BANFN[13," & cstr(x) & "]").Changeable = True Then strScreen = "0010"

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:" & strScreen & "/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-BANFN[13," & cstr(x) &  "]").Text = "xxx"

Former Member
0 Kudos

Hi Holger,

Thanks for the helpful example.

I modified it a little bit because it couldn't find the fields before check if they are changable.

Below is modified script:

session.findById("wnd[0]/tbar[0]/okcd").text = "me22n"

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

On Error resume next

If session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[10,0]").Changeable = True Then strScreen = "0010"

on error goto 0

On Error resume next

If session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0011/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[10,0]").Changeable = True Then strScreen = "0011"

on error goto 0

On Error resume next

If session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0012/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[10,0]").Changeable = True Then strScreen = "0012"

on error goto 0

On Error resume next

If session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[10,0]").Changeable = True Then strScreen = "0013"

on error goto 0

On Error resume next

If session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0014/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[10,0]").Changeable = True Then strScreen = "0014"

on error goto 0

On Error resume next

If session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[10,0]").Changeable = True Then strScreen = "0015"

on error goto 0

On Error resume next

If session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0016/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[10,0]").Changeable = True Then strScreen = "0016"

on error goto 0

On Error resume next

If session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0017/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[10,0]").Changeable = True Then strScreen = "0017"

on error goto 0

On Error resume next

If session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0018/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[10,0]").Changeable = True Then strScreen = "0018"

on error goto 0

On Error resume next

If session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0019/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[10,0]").Changeable = True Then strScreen = "0019"

on error goto 0

On Error resume next

If session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0020/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[10,0]").Changeable = True Then strScreen = "0020"

on error goto 0

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:" & strScreen & "/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[10,0]").text = "0,01"

And now it seems that work.

One more question.

Is it possible strScreen to be changed while I work for example in ME21N?

If it is possible what actions cause the change?

Regards,

Guero

holger_khn
Contributor
0 Kudos

Hello.

As far as I see the common screens from SAPLMEGUI can be used by ME21N, ME22N and ME23N. So they should be equal independence of called transaction. In ME23N this will not work as the fields are marked as Read-Only and will give FALSE back even they are visible. But for ME21N and ME23N it should be equal.

Former Member
0 Kudos

Hi Holger,

If it is not changeable then? Then what should be my next step?

holger_khn
Contributor
0 Kudos

One of you Screens should be changeable. Otherwise required action is not part of your logic and you Need to Exit logic. to avoid an vbs dump.

Former Member
0 Kudos

Please see the code which i am using:

See if you can identify anything:

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

session.findById("wnd[0]/tbar[0]/okcd").Text = "/nme21n"

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

On Error Resume Next

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-BANFN[25,0]").Text = COL1

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-BNFPO[26,0]").Text = COL3

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-BNFPO[26,0]").SetFocus

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-BNFPO[26,0]").caretPosition = 0

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

1)

If session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT9/ssubTABSTRIPCONTROL2SUB:SAPLMEGUI:1221/ctxtMEPO1222-EKORG").Changeable = True Then strScreen = "0010"

On Error GoTo 0

On Error Resume Next

If session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0020/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT9/ssubTABSTRIPCONTROL2SUB:SAPLMEGUI:1221/ctxtMEPO1222-EKORG").Changeable = True Then strScreen = "0020"

On Error GoTo 0

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:" & strScreen & "/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT9/ssubTABSTRIPCONTROL2SUB:SAPLMEGUI:1221/ctxtMEPO1222-EKORG").Text = COL15

I think the dark section is doing any problem.

Otherwise i am working with the code:

2)

Set sapobj = session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT9/ssubTABSTRIPCONTROL2SUB:SAPLMEGUI:1221/ctxtMEPO1222-EKORG", False)

If Not sapobj Is Nothing Then

  session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT9/ssubTABSTRIPCONTROL2SUB:SAPLMEGUI:1221/ctxtMEPO1222-EKORG").Select

    Else  'try 0020

      Set sapobj = session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0020/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT9/ssubTABSTRIPCONTROL2SUB:SAPLMEGUI:1221/ctxtMEPO1222-EKORG", False)

        If Not sapobj Is Nothing Then

           session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0020/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT9/ssubTABSTRIPCONTROL2SUB:SAPLMEGUI:1221/ctxtMEPO1222-EKORG").Select

       End If

      End If

This is one is working occasionally, and crashes SAP in between. I am not able to track back what is causing this. So if you could suggest any better option?

Former Member
0 Kudos

Hi Holger,

Please reply.

Your help will make my work easy. Please respond

Former Member
0 Kudos

Hi Mohan,

Just select one field from the table in ME21N and then perform the following "test" after each action like tabs changes, pressing enter etc.

x=10

On error resume next

Do Until session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:00"&x&"/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-EEIND[9,0]").changeable=true

x=x+1

Loop

On Error GoTo 0

then you could add the values to the respective fields.

Like:

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:00"&x&"/subSUB0:SAPLMEGUI:0030/subSUB1:SAPLMEGUI:1105/ctxtMEPO_TOPLINE-SUPERFIELD").text = "10"

Then if you press enter or any other GUI button you have to add the script that recognize x

I hope this will help you.

Good luck,

Guero

Answers (0)