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

SAP Scripting and Recording


I am trying to complete a repetitive task. I am going into transaction SP01. I want to add column 'output device'. I also want to filter so that any jobs with status of 'Print.', 'Proc.', 'Waiting', and ' <F5>' are filtered out. The script works when all 4 of those statuses are present in the search but when one isn't I receive the error "The control could not be found by id." Is there anyway around this? Not all SP01 searches yield all 4 statuses but I want them to be filtered permanently. Below is my current script.

Thanks! (1.1 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Oct 18, 2015 at 07:08 AM

    Hello Andrew,

    welcome to the Scripting Language forum.

    You can try this to check the existence of a control:

        Option Explicit
      '-Global Variables----------------------------------------------------
        Dim SapGuiAuto, application, connection, session
      '-Function Check------------------------------------------------------
        Function Check(ByVal Ctrl)
          Dim Result
          On Error Resume Next
          If Err.Number <> 0 Then
            Result = vbFalse
            Result = vbTrue
          End If
          On Error Goto 0
          Check = Result
        End Function
        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 Check("wnd[2]/usr/tabsTAB_STRIP/tabpNOSV/ssubSCREEN_HEADER:SAPLALDB:3030/tblSAPLALDBSINGLE_E/ctxtRSCSEL-SLOW_E[1,0]") Then
          session.findById("wnd[2]/usr/tabsTAB_STRIP/tabpNOSV/ssubSCREEN_HEADER:SAPLALDB:3030/tblSAPLALDBSINGLE_E/ctxtRSCSEL-SLOW_E[1,0]").text = "Proc."
        End If
        If Check("wnd[2]/usr/tabsTAB_STRIP/tabpNOSV/ssubSCREEN_HEADER:SAPLALDB:3030/tblSAPLALDBSINGLE_E/ctxtRSCSEL-SLOW_E[1,1]") Then
          session.findById("wnd[2]/usr/tabsTAB_STRIP/tabpNOSV/ssubSCREEN_HEADER:SAPLALDB:3030/tblSAPLALDBSINGLE_E/ctxtRSCSEL-SLOW_E[1,1]").text = "Waiting"
        End If

    The function Check try to call the ID and if the ID exists the function delivers true, otherwise false. So you have the possiblity to check the existence before you set the text. The On Error Resume Next command disables the error message box and the On Error Goto 0 enables it.

    Let us know your results.



    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 18, 2015 at 06:32 AM

    Programatically you could use on error resume next so that if the control is not found the script will carry on, regardless

    if possible with SP01 a simpler solution would be to just use a selection screen variant and layout variant to achieve the same effect.

    Add a comment
    10|10000 characters needed characters exceeded

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.