Skip to Content
avatar image
Former Member

Selection of correct SAP window using Taskbar

Hi,

I have an issue in selecting the right sytem by using macro.

I have 3 system open RP1, BP1 and SP1, but have to open RP1 sytem to run the macro further.

In the macro done by me, i can open the desired system only if it is the first open window.

The below is the codes for your ready reference.

If Not IsObject(Application1) Then

Set SapGuiAuto = GetObject("SAPGUI")

Set Application1 = SapGuiAuto.GetScriptingEngine

End If

If Not IsObject(Connection) Then

Set Connection = Application1.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 Application1, "on"

End If

Kindly let me know, how can i open the required window using the sytem name eg " SP1 (1) 510 " , by refering to the taskbar where it is displayed.

I need to open these windows from time to time to run my macro, hence need to refer them using the sytem name.

Regards,

Anup Nair

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jul 07, 2010 at 06:39 AM

    Hi Anup,

    I suspect however that the solution looks like this:

    If Not IsObject(application) Then
       Set SapGuiAuto  = GetObject("SAPGUI")
       Set application = SapGuiAuto.GetScriptingEngine
    End If
    
    for connection_number = 0 to application.children.count - 1
       Set connection = application.Children(int(connection_number))
       Set session    = connection.Children(0)
       if session.info.systemname = "SP1" then exit for
    next
    msgbox session.info.systemname
    

    Regards,

    ScriptMan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 07, 2010 at 04:16 PM

    Hi ScriptMan,

    Thanks for your quick response.

    To be more specific on my query....

    I have opened two systems SP1 client 510 and SP1 client 520.

    I need to switch between these two sytems to get the user data, some from SP1-510 while the other data from SP1-520 and feed into an excel.

    To do so, I need to switch between these two systems based on the client of the system in this case 510 and 520.

    My query is :

    Can we activate these sytems by using the task bar data as here the sytem and client are displayed eg : "SP1 (1) 510" and "SP1 (1) 520".

    Regards,

    Anup Nair

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Script Man

      Hi Scriptman,

      Thanks, but the above can be put if you need to give a condition if a particualr system is open.

      All i need is to switch from one system slient to another.

      There are two examples below, where i am stuck :

      1. System SP1 client 510 and System SP1 and client 520 are open,

      [SP1 (1) 510] and [SP1 (1) 520] are displayed in the task bar.

      Need to swith between both these at various parts in the script.

      I see only the task bar from where the sytem, client and session can be traced.

      2. System RP1 client 500 session 1 is open [ RP1 (1) 500], as displayed in the task bar and

      System RP1 client 500 session 2 is open [ RP1 (2) 500] , again displayed in the task bar.

      Need to switsh between these two from time to time.

      I see only the task bar from where the sytem, client and session can be traced into scripting.

      Kindly assist.

      Also can you suggest any good book regarding scripting wtih SAP GUI.

      Regards,

      Anup Nair

      Edited by: Anup_2010 on Jul 22, 2010 6:24 PM