cancel
Showing results for 
Search instead for 
Did you mean: 

How to count the number of open sessions

Former Member
0 Kudos

Hi Guys,

how can I Count the numer of (open) sessions?

I tried several approaches but nothing worked

(I also haven't found any discussion about this)

thanks

bw

Michael

Accepted Solutions (1)

Accepted Solutions (1)

stefan_schnell
Active Contributor
0 Kudos

Hello Michael,

you can count the number of sessions with

Connection.Children.Count

Cheers

Stefan

holger_khn
Contributor
0 Kudos

If you want to count only non-busy sessions where Scripting is enabled below function will give number of sessions according to filter criteria.

Public Function CountSessions() As Integer

    Dim iSession As Integer

    iSession = 0
   
    If oSAP_APP Is Nothing Then Set oSAP_APP = SAP_Applic
   
    If Not oSAP_APP Is Nothing Then
        For Each oConnection In oSAP_APP.Children
            If Not oConnection.DisabledByServer Then
                For Each oSession In oConnection.Children
                    If oSession.Busy = False Then
                        iSession = iSession + 1
                    End If
                Next
            End If
        Next
    End If
   
    CountSessions = iSession
   
End Function

stefan_schnell
Active Contributor
0 Kudos

Hello Michael,

to count the open session windows, which means the windows that are not iconified, you can try this:

  OpenWin = 0

  For i = 0 To connection.children.count - 1

    Set session = Connection.Children(CInt(i))

    If session.busy = false Then

      Set window = session.activewindow

      If window.iconic = false Then

        OpenWin = OpenWin + 1

      End If

    End If

  Next

  MsgBox OpenWin

Let us know your results.

Cheers

Stefan

Answers (1)

Answers (1)

Former Member
0 Kudos

Thank you very very much for the quick respone to all of you

thanks

br

Michael