Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Sap Standard Screen Selection

I have a number of Scripts that edit the selection screen, currently I have created a selection screen variant for each of the transactions that can be loaded to ensure that all user options are cleared, however the system periodically deletes these variants and I have to create them again,

is there a way to clear the screen selection using Sap GUI Script or is there a way to specify the selection screen to use the system default variant?

Thanks,

    Robin

Tags:
Former Member
replied

Hello Robin,

welcome in the Scripting Language forum.

The following script deletes all entries of a selection screen:

'-Begin-----------------------------------------------------------------

  '-Directives----------------------------------------------------------

    Option Explicit

'-Global Variables----------------------------------------------------

    Dim SapGuiAuto, application, connection, session

  '-Sub EmptyTextFields------------------------------------------------

    Sub EmptyTextFields(obj)

      '-Variables-------------------------------------------------------

        Dim cntObj, i, Child, Field

     On Error Resume Next

      cntObj = obj.Children.Count()

      If cntObj > 0 Then

        For i = 0 To cntObj - 1

          Set Child = obj.Children.Item(CLng(i))

          EmptyTextFields Child

          If InStr(Child.ID(), "/usr/") Then

            If InStr(Child.ID(), "-LOW") Or InStr(Child.ID(), "-HIGH") Then

              Set Field = Child.Parent().FindByID(Child.ID())

              Field.Text = ""

            End If

          End If

        Next

      End If

      On Error Goto 0

     End Sub

'-Main----------------------------------------------------------------

    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

    EmptyTextFields session

'-End-------------------------------------------------------------------

It deletes all entries in fields which ID ends with an -LOW or -HIGH. In a selection screen you have in a normal case this scheme of ID names. If your selection screen follows another scheme, change the code in line 17.

Let us know your results and if this code has solved your problem.

Cheers

Stefan

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question