Hi, I am simulating the following:
Open one or more SAP session and afterwards switch off the connection (with can happen)
System will pop up the Message Box: WSAECONNRESET: Conection Reset by Peer.
When I run any VBA or VBS Script it looks "OK" because system still considering the SAP Logon Window Opened and also a SAP session active.
Basically all objects (I am considering) are still valid.
Do you know any way to get this error on in order to kill SAP run (like in task manager) or any order way?
and restablish a new conection?
I am using an example got from StackOverflow, but I have tested many others with similar results"
Sub sap() If SAP_Connection Then MsgBox ("Sap is Open so just attached to session(0)") Else MsgBox ("Sap is NOT open so open Logon Window") End If End Sub
Function SAP_Connection() As Boolean On Error GoTo ErrSap If Not IsObject(SapApplication) Then Set SapGuiAuto = GetObject("SAPGUI") Set SapApplication = SapGuiAuto.GetScriptingEngine End If If Not IsObject(connection) Then Set connection = SapApplication.Children(0) End If If Not IsObject(session) Then Set session = connection.Children(0) End If If IsObject(WScript) Then WScript.ConnectObject session, "on" WScript.ConnectObject SapApplication, "on" End If Set session = Nothing SAP_Connection = True Exit Function ErrSap: SAP_Connection = False End Function
Thanks and appreciate any help on this.