on 05-15-2014 11:42 AM
Dear Experts,
I’m trying to build a procedure which will be checking all open session with SAP.
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?
Hi,
The AL08 transaction should be integrated for complete list of logon users.
Regards,
Vamshi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.