Skip to Content

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

Check all open sessions

Dear Experts,

I’m trying to build a procedure which will be checking all open session with SAP.

Some time ago I found that great procedure made by Sayuti Azmi. I made small changes I now I able to check what session/and t-codes are open.

But if I will login to SAP with two different users, (me + someone else) second user is not visible for that script.

General idea is to build procedure to validate who is login in to SAP on a specific computer.

Sub CheckAllOpenSessions()

Dim SapGuiAuto As Object

Dim i As Integer

Dim iSession As Integer

Dim sapapplication

Dim Connection As SAPFEWSELib.GuiConnection

Dim Session As SAPFEWSELib.GuiSession

Dim strSessions As String

   i = 1

    iSession = 0

    ' There may be bad entries in the ROT from previous crashes

    While i < 10 And SapGuiAuto Is Nothing

      i = i + 1

       On Error Resume Next

       Set SapGuiAuto = GetObject("SAPGUI")

      On Error GoTo 0




    If SapGuiAuto Is Nothing Then

        MsgBox "Could not connect to SAPlogon process. Did you start it?"

        Exit Sub

    End If


    On Error Resume Next

    Set sapapplication = SapGuiAuto.GetScriptingEngine

    Set SapGuiAuto = Nothing

    On Error GoTo 0

    If sapapplication Is Nothing Then

        MsgBox "Could not access GuiApplication. Maybe Scripting is disabled?"

        Exit Sub

    End If

    Set SapGuiAuto = Nothing

    For Each Connection In sapapplication.Children

        If Not Connection.DisabledByServer Then

            For Each Session In Connection.Children


               If Session.Busy = False Then

                   iSession = iSession + 1

                        For x = 1 To iSession

Sheets(1).Cells(iSession, 1) = Session.Info.SessionNumber

Sheets(1).Cells(iSession, 2) = Session.Info.SystemName

Sheets(1).Cells(iSession, 3) = Session.Info.User

Sheets(1).Cells(iSession, 4) = Session.Info.Transaction


                End If


       End If


end sub


1TEST SYSTEM S000Just open window of SAP not logged in

How to check if there is more than one user login to SAP?

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