Skip to Content
avatar image
Former Member

How to access/extract the details of XML from sxi_monitor, SAPLogon.ini

Hi All,

Can someone help me/suggest is there a way that I can get the XML/XML Content from the T-code -> SXI_MONITOR using backend code/macros?

I work with SAP CRM for which the SAPLogon GUI is the backend where values are mapped to our CRM Application. Im aware of connecting the SAP from macros, but not able to figure out how to read or identify the XMLs that are triggerd by different interfaces when we do certain actions in the frontend. So it would be really help full if you could help me out if there is any way out for this.

Thanks in advance

Regards,

NND

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Oct 22, 2015 at 06:07 AM

    Hello Nagadarshan,

    welcome in the Scripting Language forum.

    Here an example how to read the complete GridView. In this example the GridView is stored as csv file.

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

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

        Option Explicit

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

        Dim SapGuiAuto, application, connection, session

        Dim Grid, Columns, i, j, Text, FSO, GridFile

      '-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

        '-Get the grid object-----------------------------------------------

          Set Grid = session.FindById("wnd[0]/usr/cntlMSGLIST/shellcont/shell/shellcont[1]/shell")

        '-Get the columns---------------------------------------------------

          Set Columns = Grid.ColumnOrder()


        '-Loop to read each line of the grid--------------------------------

          For i = 0 To Grid.RowCount() - 1                 'Line by line

            For j = 0 To Grid.ColumnCount() - 1            'Column by column

              If j = 0 Then

                Text = Text & Grid.GetCellValue(i, CStr(Columns(j)))

              ElseIf j > 0 And j < Grid.ColumnCount() - 1 Then

                Text = Text & ";" & Grid.GetCellValue(i, CStr(Columns(j)))

              ElseIf j = Grid.ColumnCount() - 1 Then

                Text = Text & ";" & Grid.GetCellValue(i, CStr(Columns(j))) & vbCrLf

              End If

            Next

            '-Refreshes the grid, necessary because not all lines are cached

              If i Mod 32 = 0 Then

                Grid.SetCurrentCell i, CStr(Columns(0))

              End If

          Next

        '-Stores the data of the grid in a text file------------------------

          Set FSO = CreateObject("Scripting.FileSystemObject")

          Set GridFile = FSO.CreateTextFile("c:\dummy\grid.txt", True, False)

          GridFile.Write(Text)

          GridFile.Close

        MsgBox "Ready"

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

    On this way you can read the whole grid, or the columns that you definitely need. Look at the GuiGridView object in the help file for more information. Also look specially at the method GetColumnTitle.

    Let us know your results.

    Cheers

    Stefan

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Nagadarsharn,

      I check it in Excel-VBA, it is necessary, if you want to use SAP GUI Scripting, that the SAP Logon is running and one session with your transaction code is open. Otherwise you get the error message. In my case I get exact the same message as you - only in German.

      Please try it an let us know your result.

      I open a session and check the source above with the transaction code SXI_MONITOR and Status Group System Error. My only open session looks like this:

      My VBA code is this:

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

        Option Explicit

      Sub Test()

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

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

          Dim SapGuiAuto, application, connection, session

          Dim Grid, Columns, i, j, Text, FSO, GridFile

        '-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

          '-Get the grid object-------------------------------------

            Set Grid = _

              session.FindById("wnd[0]/usr/cntlMSGLIST/shellcont/" & _

                "shell/shellcont[1]/shell")

          '-Get the columns-----------------------------------------

            Set Columns = Grid.ColumnOrder()

          '-Loop to read each line of the grid----------------------

            For i = 0 To Grid.RowCount() - 1       'Line by line

              For j = 0 To Grid.ColumnCount() - 1  'Column by column

                If j = 0 Then

                  Text = Text & Grid.GetCellValue(i, CStr(Columns(j)))

                ElseIf j > 0 And j < Grid.ColumnCount() - 1 Then

                  Text = Text & ";" & Grid.GetCellValue(i, _

                    CStr(Columns(j)))

                ElseIf j = Grid.ColumnCount() - 1 Then

                  Text = Text & ";" & Grid.GetCellValue(i, _

                    CStr(Columns(j))) & vbCrLf

                End If

              Next

              '-Refreshes the grid----------------------------------

                If i Mod 32 = 0 Then

                  Grid.SetCurrentCell i, CStr(Columns(0))

                End If

            Next

          '-Stores the data of the grid in a text file-------------

            Set FSO = CreateObject("Scripting.FileSystemObject")

            Set GridFile = FSO.CreateTextFile("c:\dummy\grid.txt", _

              True, False)

            GridFile.Write (Text)

            GridFile.Close

          MsgBox "Ready"

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

      End Sub

      It runs as expected.

      Let us know your results.

      Cheers

      Stefan

      005.JPG (21.1 kB)
      006.jpg (30.2 kB)