Skip to Content
author's profile photo Former Member
Former Member

Variables in a SAP GUI Script

Hi All, -

Can somebody tell me, how can I use a variable instead of hardcoded value into a SAP GUI script?

Because the recorded file is a vbs-file, I have tried to declare a variable as usual:


Dim Count As Integer
Count  = 58


But when I try to execute the updated script, even without assigning the Count variable to any places from the script, an error occurs u2013 u2018expected end of statementu2019 (the same error also occurs if I use Count instead of 58). Actually I want to replace all occurrences of number 58 in the script below. Can anybody help me?





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/tabsTS_SCRIPT_EDITOR_0202/tabpECSC_ED/ssubTR_SCRIPT_REF1:SAPLECATT_MAIN:0402/cntlCC_ECSC_EDITOR/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell/shellcont[1]/shell/shellcont[1]/shell").currentCellColumn = "DATA"
session.findById("wnd[0]/usr/tabsTS_SCRIPT_EDITOR_0202/tabpECSC_ED/ssubTR_SCRIPT_REF1:SAPLECATT_MAIN:0402/cntlCC_ECSC_EDITOR/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell/shellcont[1]/shell/shellcont[1]/shell").modifyCell 0,"DATA","M_FORMOFADDR"
session.findById("wnd[0]/usr/tabsTS_SCRIPT_EDITOR_0202/tabpECSC_ED/ssubTR_SCRIPT_REF1:SAPLECATT_MAIN:0402/cntlCC_ECSC_EDITOR/shellcont/shell/shellcont[0]/shell").insertRows "58"
session.findById("wnd[0]/usr/tabsTS_SCRIPT_EDITOR_0202/tabpECSC_ED/ssubTR_SCRIPT_REF1:SAPLECATT_MAIN:0402/cntlCC_ECSC_EDITOR/shellcont/shell/shellcont[0]/shell").modifyCell 58,"PNAME","M_FORMOFADDR"
session.findById("wnd[0]/usr/tabsTS_SCRIPT_EDITOR_0202/tabpECSC_ED/ssubTR_SCRIPT_REF1:SAPLECATT_MAIN:0402/cntlCC_ECSC_EDITOR/shellcont/shell/shellcont[0]/shell").modifyCell 58,"PTYP","I"
session.findById("wnd[0]/usr/tabsTS_SCRIPT_EDITOR_0202/tabpECSC_ED/ssubTR_SCRIPT_REF1:SAPLECATT_MAIN:0402/cntlCC_ECSC_EDITOR/shellcont/shell/shellcont[0]/shell").setCurrentCell 58,"PTYP"
session.findById("wnd[0]/usr/tabsTS_SCRIPT_EDITOR_0202/tabpECSC_ED/ssubTR_SCRIPT_REF1:SAPLECATT_MAIN:0402/cntlCC_ECSC_EDITOR/shellcont/shell/shellcont[0]/shell").firstVisibleRow = 53


Edited by: Svetlana Balinova on Jul 21, 2009 3:12 PM

Edited by: Svetlana Balinova on Jul 21, 2009 3:13 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Jul 21, 2009 at 02:31 PM

    Hi Svetlana,

    if I have understood correctly, could it be that the following link you could use a bit:

    Referencing a variable in 'session findbyId' command (SAP GUI Scripting)



    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Scriptman,

      Thanks a lot for your help. The problem disappears when I use a variant (Dim Count) instead of another more concrete data type (Dim Count As Integer).

      Kind Regards:


      Edited by: Svetlana Balinova on Jul 22, 2009 10:30 AM

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.