cancel
Showing results for 
Search instead for 
Did you mean: 

Check all open sessions

Former Member
0 Kudos

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.SessionNumberSession.Info.SystemNameSession.Info.UserSession.Info.TransactionComment
1MAIN SYSTEMUSER1SESSION_MANAGER
2MAIN SYSTEMUSER1SU53
3MAIN SYSTEMUSER1MM50
4MAIN SYSTEMUSER1ZQM1_001
1TEST SYSTEM S000Just open window of SAP not logged in

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

Accepted Solutions (0)

Answers (1)

Answers (1)

vamshi_mohan
Participant
0 Kudos

Hi,

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

Regards,

Vamshi.

Former Member
0 Kudos

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.