Skip to Content

Sap scripts not working when shared by other users

I have been creating scripts for various tasks within my department and I am having issues with GUI scripting. When I try to share my recorded scripts with other users in my work group they do not work. I have set their varient to the exact same as mine so our tables align, their ui may be scaled larger than mine is however, the tables are still the same layout.

Whenever they attempt to use one of my scripts they receive an error and the script does not process. I record their own script on their own machine clicking in the same spots and entering the same data and it will work on their computers. It is driving me mad trying to figure out this issue as I have over 40 scripts that I need to share with them.

I am able to use the scripts that are recorded on their computers on mine.

Here is an example of a script for a simple task:

If Not IsObject(application) Then
   Set SapGuiAuto  = GetObject("SAPGUI")
   Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
   Set connection = application.Children(0)
End If
If Not IsObject(session) Then
   Set session    = connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject session,     "on"
   WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]/usr/ctxtRIWO00-QMNUM").text = "409231479"
session.findById("wnd[0]/usr/ctxtRIWO00-QMNUM").caretPosition = 9
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_3:SAPLIQS0:7336/tblSAPLIQS0MASSNAH_VIEWER3").getAbsoluteRow(0).selected = true
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_3:SAPLIQS0:7336/tblSAPLIQS0MASSNAH_VIEWER3/ctxtVIQMSM-MNGRP[0,0]").text = "JP-2R"
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_3:SAPLIQS0:7336/tblSAPLIQS0MASSNAH_VIEWER3/ctxtVIQMSM-MNCOD[1,0]").text = "6046"
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_3:SAPLIQS0:7336/tblSAPLIQS0MASSNAH_VIEWER3/txtVIQMSM-MATXT[3,0]").text = "8"
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_3:SAPLIQS0:7336/tblSAPLIQS0MASSNAH_VIEWER3/ctxtVIQMSM-PSTER[6,0]").text = "4/24/18"
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_3:SAPLIQS0:7336/tblSAPLIQS0MASSNAH_VIEWER3/ctxtVIQMSM-PETER[7,0]").setFocus
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_3:SAPLIQS0:7336/tblSAPLIQS0MASSNAH_VIEWER3/ctxtVIQMSM-PETER[7,0]").caretPosition = 0
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_3:SAPLIQS0:7336/btnFC_ERLEDIGT").press
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_2:SAPLIQS0:7715/cntlTEXT/shellcont/shell").setSelectionIndexes 0,0
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_3:SAPLIQS0:7336/btnDETAL").press
session.findById("wnd[1]/tbar[0]/btn[5]").press
session.findById("wnd[1]/usr/ctxtVIQMSM-MNCOD").text = "EJPA"
session.findById("wnd[1]/usr/ctxtVIQMSM-MNCOD").setFocus
session.findById("wnd[1]/usr/ctxtVIQMSM-MNCOD").caretPosition = 4
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]/usr/txtVIQMSM-MATXT").text = "8"
session.findById("wnd[1]/usr/ctxtRQM02-NAME_QMSM").setFocus
session.findById("wnd[1]/usr/ctxtRQM02-NAME_QMSM").caretPosition = 0
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]/usr/ctxtRQM02-NAME_QMSM").text = "ROMORD"
session.findById("wnd[1]/usr/ctxtRQM02-NAME_QMSM").setFocus
session.findById("wnd[1]/usr/ctxtRQM02-NAME_QMSM").caretPosition = 6
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]/usr/btnFREIGEGEBEN").press
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]/usr/ctxtVIQMSM-PETER").text = "4/29/18"
session.findById("wnd[1]/usr/ctxtVIQMSM-PETER").setFocus
session.findById("wnd[1]/usr/ctxtVIQMSM-PETER").caretPosition = 7
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]/tbar[0]/btn[6]").press
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_2:SAPLIQS0:7715/cntlTEXT/shellcont/shell").setSelectionIndexes 0,0
session.findById("wnd[0]/usr/subSCREEN_1:SAPLIQS0:1050/subNOTIF_TYPE:SAPLIQS0:1051/txtVIQMEL-QMTXT").text = "E6079-409231479"
session.findById("wnd[0]/usr/subSCREEN_1:SAPLIQS0:1050/subNOTIF_TYPE:SAPLIQS0:1051/txtVIQMEL-QMTXT").caretPosition = 0
session.findById("wnd[0]/usr/subSCREEN_1:SAPLIQS0:1050/btnANWENDERSTATUS").press
session.findById("wnd[1]/usr/tblSAPLBSVATC_E/radJ_STMAINT-ANWS[0,1]").selected = true
session.findById("wnd[1]/usr/tblSAPLBSVATC_E/radJ_STMAINT-ANWS[0,1]").setFocus
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_2:SAPLIQS0:7715/cntlTEXT/shellcont/shell").setSelectionIndexes 0,0
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1100/tabsTS_1100/tabpIOLU").select
session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1107/subSUB_KOPF:SAPLCOIH:1108/txtCAUFVD-KTEXT").text = "E6079-409231479"
session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1107/subSUB_KOPF:SAPLCOIH:1108/txtCAUFVD-KTEXT").caretPosition = 15
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1107/tabsTS_1100/tabpIOLU/ssubSUB_AUFTRAG:SAPLIWOL:0300/tblSAPLIWOLOBJK_120/ctxtRIWOL-TPLNR[2,2]").text = "OH-4625705E"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/tbar[0]/btn[11]").press

Add a comment
10|10000 characters needed characters exceeded

  • Hello Ruben,

    welcome in the SAP Community.

    Which error message do you get? Do you can upload an image with the error message dialog? If we have this information we could better understand your problem and help you.

    Thanks and best regards
    Stefan

  • additionally, you are describing a comparison between recordings doing "the same thing" that are behaving differently.

    It would be useful to be able to compare the 2 scripts to see the differences in the recorded code.

    Side note: lines ending in .caretPosition = XX are generally unnecessary. This is the recorded location of the input cursor. Removing these redundant steps can also help clean up the recordings readability.

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Sep 26, 2018 at 02:13 PM

    Hi Ruben,

    I bet this is an application which has dynamic subscreen IDs.

    My recommendation is that you pick one line from one of your scripts and see how the same action is recorded for another user

    session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB01/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_2:SAPLIQS0:7715/cntlTEXT/shellcont/shell").setSelectionIndexes 0,0

    In many cases the subscreen numbers in paths like this will be different:
    subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_2:SAPLIQS0:7715

    If this is the issue, it will be tricky to solve as the application creates these IDs dynamically, but SAP GUI expects exactly the recorded ID.

    Best regards,
    Frank

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 20, 2018 at 04:30 AM

    I have the same issue at my workplace. We create Excel macros that access SAP to do various things. I run the macros and they do not work for me. All others in the groups run the Excel macros and the macros work as intended and update SAP accordingly. In one instance, from what I was told from someone who was able to reprogram the macro for me, it had to do with the macro trying to copy and paste a certain field in SAP, but it was not finding the field, and the macro failed at that step. He reprogrammed that section of the code to "click" into section, "scroll" down, "select" field, "copy" field etc.

    I am currently checking SAP options and configurations against other users for which the macros do work.

    If you find out any more info of why this did not work for your other users, I would love to hear your findings. I would love to know what worked for you.

    Thank you!

    Add a comment
    10|10000 characters needed characters exceeded