Hello Stefan,
Thanks for the response. I have tried your code which works and creates a new session. But I still have some minor issues with the flow.
1. If i have 3 sessions open and i execute the red marked code, then the system connects all the open sessions. In the end i have then 3 different sessions connected.
For Each Connection In sapapplication.Children
If Not Connection.DisabledByServer Then
For Each session In Connection.Children
If session.Busy = False Then
If session.info.Transaction = "SESSION_MANAGER" Then
Session_Nr = session.info.sessionnumber - 1
Set session = Connection.Children(Int(Session_Nr))
session.TestToolMode = 1
Exit Sub
End If
End If
Next
End If
Next
2. Further if one of these three sessions is not being used, then the system tries to connect to this open session (blue code) and this triggers an error.
The requirement is following.
1. Scan all the open sessions
2. Find the session without a transaction associated
3. If a session is found then connect this session and activate it. All other sessions are not connected anymore.
4. If no session is found, then create a session, activate it and use it for the new transaction.
Thanks for your help,
Amit