Question

Detecting an SAP Session

  • 17 January 2024
  • 3 replies
  • 33 views

Userlevel 2
Badge +8

Does anyone know how to detect if an SAP Session has been initiated or not? Like in an IF statement. I don’t mean SAP itself, just if the SAP Connect action has resulted in an active session for use in AA.

I’ve placed the SAP Disconnect action in the catch of my error trapping to disconnect if there are errors. But I only want it to execute if there’s an active session. I’m thinking of moving the Disconnect action to a Finally section of error handling, but I think I may still experience issues if there’s not an active session.


3 replies

Userlevel 3
Badge +9

This is not SAP, but we use a standard code block at our firm to manage the connect to/disconnect from actions for our database. It attempts to connect in a nested error handling block and loops 10 times. We are basically giving the connection 10 chances to fail. If, after 10 iterations, it still has not connected, then the code moves on to user-defined error handling.

 

In your case, if the SAP disconnect fails x number of times, then you could assume it is already disconnected, and then move to the end of your task as usual.

 



Hope this helps.

Userlevel 2
Badge +8

Interesting approach! I can use that. I also need to account for errors that happen before the disconnect takes place which lands me down into the catch and the finally before that code would run though.

Userlevel 2
Badge +8

I think what I might do is create a Boolean variable and set it to true after the Connect action. Then set it to false after the Disconnect action. If it’s still true when I get to the catch or finally then I can use that to determine if I need to Disconnect. Sure wish the “session” had a property to check though!

Reply