'-Begin--------------------------------------------------------------
'-Directives-------------------------------------------------------
Option Explicit
'-Function GetConnectionNo-----------------------------------------
'-
'- Function to get connection number of the given SID with
'- logon screen
'-
'------------------------------------------------------------------
Function GetConnectionNo(Application, SID)
'-Variables----------------------------------------------------
Dim i, Connection, SessionInfo, ConnectionNo
If Application.Children.Count > 0 Then
For i = 0 To Application.Children.Count - 1
Set Connection = Application.Children(CInt(i))
Set SessionInfo = Connection.Children(0).Info
If SessionInfo.SystemName = SID And _
SessionInfo.Program = "SAPMSYST" Then
ConnectionNo = Mid(Connection.Id, InStr(Connection.Id, "[") + 1)
ConnectionNo = Left(ConnectionNo, Len(ConnectionNo) - 1)
GetConnectionNo = CStr(ConnectionNo)
End If
Next
Else
GetConnectionNo = -1
End If
End Function
'-Sub Main---------------------------------------------------------
Sub Main()
'-Variables----------------------------------------------------
Dim SapGuiAuto, Application, ConnNo
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Application = SapGuiAuto.GetScriptingEngine
End If
ConnNo = GetConnectionNo(Application, "NSP")
MsgBox ConnNo
End Sub
'-Main-------------------------------------------------------------
Main
'-End----------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |