on ‎2009 Feb 06 2:14 PM
Hi,
how to activate an active SAP-session via Gui Scripting or maybe a workaround?
There are some SAP sessions running and I want to activate a certain one of them.
I tried to activate a session with:
AppActivate session.findById("wnd[0]").Text
but, as we know, if there are the same task names in Task Manager, the function will start any one of them.
Any idea?
Edited by: Stefan Benkö on Feb 9, 2009 7:07 AM
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
Hello Stefan,
If I understand correctly, you are logged into different instances e.g. ECD(100), ECD(120), ECQ(100) etc. and you want to pick a specific log-in.
Here is what I do in script. (Where W_System = ECQ100 etc.)
Dim il, it
Dim W_conn, W_Sess, W_System
W_System = objSheet.Cells(iRow, 1)
If Not objSess Is Nothing Then
If objSess.Info.SystemName & objSess.Info.Client = W_System Then
Exit Function
End If
End If
If objGui Is Nothing Then
Set SapGuiAuto = GetObject("SAPGUI")
Set objGui = SapGuiAuto.GetScriptingEngine
End If
For il = 0 To objGui.Children.Count - 1
Set W_conn = objGui.Children(il + 0)
For it = 0 To W_conn.Children.Count - 1
Set W_Sess = W_conn.Children(it + 0)
If W_Sess.Info.SystemName & W_Sess.Info.Client = W_System Then
Set objConn = objGui.Children(il + 0)
Set objSess = objConn.Children(it + 0)
Exit For
End If
Next
Next
If objSess Is Nothing Then
MsgBox "Not Logged into system"
End If
If IsObject(WScript) Then
WScript.ConnectObject objSess, "on"
WScript.ConnectObject objGui, "on"
End If
Hope this helps. Further if you have multiple sessions in the system you can add further check e.g. "Transaction" property etc.
Best regards,
Nitin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.