cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

stefan_schnell
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hello Stefan,

Thanks alot for the response.

Above Error on the line

Automation error

Invalid syntax

---------------->  Set SapGuiAuto = GetObject("SAPGUI")

also Is there any Reference.. or add-Ins that I should add?

looking ahead for the answer

Regards,

NND

holger_khn
Contributor
0 Kudos

Hello. As you run Code from VBA you Need To rename Variable 'application' aus this is User by VBA Library. Change it To 'sapapplic'. That will solche your issues.

stefan_schnell
Active Contributor
0 Kudos

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

Answers (0)