cancel
Showing results for 
Search instead for 
Did you mean: 

Actual SAP connection number

Former Member
0 Kudos

Im trying to find out how I can tell which SAP connection I am looking at. I have written some code in Visual Basic that gets the available connections:


For conno = 0 To (application.connections.Count - 1)
    Set connection = application.connections.Item(CLng(conno))
.
.

Now, the application.connections object is a VB collection. This grows and shrinks with the number of objects within it. A connection object that was at position 5 could move down to position 4 if another connection dissapears.

The problem is that SAP has maintained the existing number of 5 for that connection. What I need to know is how I can get a hold of that number?

It is available on the GuiSessionInfo object under the property 'sessionNumber'. I need something similar for the connection.

Any ideas?

Accepted Solutions (1)

Accepted Solutions (1)

CountZero
Explorer
0 Kudos

Hi,

Do you need the actual number? From your example you look like you are just iterating through the application connections. What you can do is use For..each. So in your below example you could do the following

for each connection in application.connections
   'connection object now points to the current connection
   'in the iteration
   connection.logoff
next

That way you don't need the actual connection number unless you require it.

Answers (1)

Answers (1)

Former Member
0 Kudos

Ive been working on another project for a while now and so didnt get a chance to work through this problem. A fresh look and I understand how to do it.

I get the 'id' property of the connection object and then just strip the number out of the string.

ie, the id of a connection looks like:

/app/con[0] ... or whatever number

When Ive created a few different connections and then terminated the earlier ones, the indexes remain true. If you create 3 connections and kill the first one then the existing connection indexes will be 2 and 3. Exactly what I need.

Thanks for the response in the last post, although it wouldnt solve my problem here, Ive used the 'for each' loop against sessions with success.