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.
Hi Stefan,
I have had success identifying the Excel VBA objects by viewing the Locals Window in Excel VBA while stepping through the code.
The sessions will be in a collection beginning with item 0. You can select a session and specify the session using the collection item number.
If you need to activate the specified session, try GetObject ("SAPGUI")
Best Regards,
Casimir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stefan,
I also have a longer period of time similar problems which I am on a different way to solve that. A professional solution to this problem is haggard to me thanks "GuiXT".
For example:
1. It is a script to:
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.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 application, "on"
End If
session.findById("wnd[0]").maximize
...
2. It replaces the first 14 lines as follows:
set aw = session.activeWindow()
aw.findById("wnd[0]").maximize
...
3. If a window change is taking place:
set aw = session.activeWindow()
aw.findById("wnd[0]").maximize
aw.findById("wnd ......").press
set aw1 = session.activeWindow()
aw1.findById("wnd[1]/tbar[0]/btn[0]").press
...
I think that this problem is not only both of us interested. Unfortunately, this script only adapted from SAP to start. At a general validity is still under construction.
Regards,
ScriptMan
Edited by: ScriptMan on Jun 23, 2009 2:24 PM
Edited by: ScriptMan on Jun 23, 2009 2:51 PM
Hi,
a general solution, I have not yet. Perhaps some of you have it perfect.
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.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 application, "on"
End If
set aw = session.activeWindow()
aw.findById("wnd[0]").maximize
on error resume next
SESSION_ = 0
do
err.clear
aw.findById("wnd.......").press
if err.number = 0 or SESSION_ = (connection.children.count - 1) then exit do
SESSION_ = SESSION_ + 1
Set session = connection.Children(int(SESSION_))
set aw = session.activeWindow()
loop
set aw1 = session.activeWindow()
aw1.findById("wnd[1]/tbar[0]/btn[0]").press
on error goto 0
There is still a problem when multiple modes include the same transaction.
Regards,
ScriptMan
Edited by: ScriptMan on Jun 25, 2009 8:20 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.