Skip to Content
avatar image
Former Member

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

    Wend

   

   

    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

                        Next

                End If

            Next

       End If

    Next

end sub

Result:

Session.Info.SessionNumber Session.Info.SystemName Session.Info.User Session.Info.Transaction Comment 1 MAIN SYSTEM USER1 SESSION_MANAGER 2 MAIN SYSTEM USER1 SU53 3 MAIN SYSTEM USER1 MM50 4 MAIN SYSTEM USER1 ZQM1_001 1 TEST SYSTEM S000 Just open window of SAP not logged in

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • May 15, 2014 at 11:18 AM

    Hi,

    The AL08 transaction should be integrated for complete list of logon users.

    Regards,

    Vamshi.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      Good point, but im a end user i will never get authorization to AL08 i guess that's SAP BASIC t-code.

      I have to do that from SAP GUI SCRIPTING level.