cancel
Showing results for 
Search instead for 
Did you mean: 

Get Systeminfo

Former Member
0 Kudos

Hi,

how can i get the syteminfo by script (VbScript / VBA) ?

Sub SAP_Info()    

    Set SapGuiAuto = GetObject("SAPGUI")

    Set SAP = SapGuiAuto.GetScriptingEngine

   

    ' get Transaction: VA03

    Debug.Print SAP.Children(0).Children(0).info.transaction

    ' get Windowtitle: Change Sales Order: Initial Screen

    Debug.Print SAP.Children(0).Children(0).findbyid("wnd[0]").Text

End Function

Thanks, Mike

Accepted Solutions (1)

Accepted Solutions (1)

script_man
Active Contributor
0 Kudos

Hi Mike,

please try to use the following:

      instead the command Debug.Print the command msgbox

Regards,

ScriptMan

Former Member
0 Kudos

Hi ScriptMan,

the Code works fine with Debug.Print, but i'm looking for the Systemnumber, -name or -ID of the Connection like 'P01', 'T02'.

Thx, Mike

script_man
Active Contributor
0 Kudos

Hi Mike,

sorry, I misunderstood it. The other commands are as follows:

msgbox "SessionNumber: " & SAP.Children(0).Children(0).info.sessionnumber

msgbox "SystemName: " & SAP.Children(0).Children(0).info.systemname

msgbox "SystemNumber: " & SAP.Children(0).Children(0).info.systemnumber

msgbox "SystemSessionID: " & SAP.Children(0).Children(0).info.systemsessionid

msgbox "Client: " & SAP.Children(0).Children(0).info.client

Regards,

ScriptMan

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi ScriptMan,

THANK YOU VERY MUCH 🙂

It works perfect!

Thx, Mike

Former Member
0 Kudos

Hi Scriptman,

thank you very much.

I have one more question 🙂

How can i loop trough the Connections and Sessions?

The Code below doesn't wotk 🙂

Sub Get_SAP_Info()

   Dim iCon    As Integer

   Dim iSes    As Integer

   Dim sText   As String

  

   On Error Resume Next

  

   Set SapGuiAuto = GetObject("SAPGUI")

   Set SAP = SapGuiAuto.GetScriptingEngine

     

   ' Systeminfo -> Works fine 🙂

'   Debug.Print "SessionNumber: " & SAP.Children(0).Children(0).info.sessionnumber

'   Debug.Print "SystemName: " & SAP.Children(0).Children(0).info.systemname

'   Debug.Print "SystemNumber: " & SAP.Children(0).Children(0).info.systemnumber

'   Debug.Print "SystemSessionID: " & SAP.Children(0).Children(0).info.systemsessionid

'   Debug.Print "Client: " & SAP.Children(0).Children(0).info.client

     

   ' Loop trough Connections

   For iCon = 0 To SAP.Children.Count - 1

      Set Connection = SAP.Children(iCon)

  

      ' Loop trough Sessions

      For iSes = 0 To Connection.Children.Count - 1

         Set Session = Connection.Children(iSes)

        

         If Session.info.transaction <> "" Then

            Debug.Print Session.info.systemname

            Debug.Print Session.info.transaction

            Debug.Print Session.findbyid("wnd[0]").Text

         End If

      Next

   Next

     

   ' Errors?

   If Err.Number <> 0 Then

      Debug.Print Err.Number & " - " & Err.Description

   End If

  

   Set SapGuiAuto = Nothing

   Set SAP = Nothing

End Sub

Thx, Mike

script_man
Active Contributor
0 Kudos

Hi Mike,

please try the following:

Sub Get_SAP_Info()

   ' Deactivate the following 2 lines

   ' Dim iCon    As Integer

   ' Dim iSes    As Integer

. . .

Set Connection = SAP.Children(Int(iCon))

. . .

Set Session = Connection.Children(Int(iSes))

. . .

End Sub

Regards,

ScriptMan