cancel
Showing results for 
Search instead for 
Did you mean: 

How to Attach to SAP Window.

SasiAnbalagan
Level 4
I have a need of opening up two different SAP GUI Windows and I will be switching these windows during my process, what is the best approach to attach to SAP Window, I tried to us Window Text but not much of help with that.
2 REPLIES 2

IanGrant
Level 3
Hi, As per our other conversation, I strongly advise that you review the SAP GUI Scripting Help that SAP publishes. Understanding the SAP GUI model will aid you in understanding how to manage the automation process. In short, SAP uses a App/Connection/Session/Window model. Your question most likely relates to the session level of the hierarchy as this is how most end users view the session stage. Examine how BP models SAP elements. Each ID is based upon this SAP GUI model as the SAP GUI API itself uses it. You will benefit greatly from understanding the SAP GUI hierarchy as it directly relates to the elements within BP. Continuing my assumption that you're referring to multiple sessions, you can manage it within the application modeler. Your first session would be interacted with using Match IDs of /app/con[0]/ses[0]/wnd[0] Your second session would be interacted with using Match IDs  of /app/con[0]/ses[1]/wnd[0] Note 1) that wnd[0] is the main window of the session. As SAP generates modal windows within the same session this will increment upwards to wnd[1] then wnd[2] and so on. Note 2) that the existence of multiple sessions forces you to spend more time on the object layer development. You need to approach every SAP object with a mindset of dynamic referencing. Your object should accept session and window (and potentially even connection) as inputs. These inputs can then direct the object towards the correct session and window to operate upon. Note 3) that you will need to completely rethink the way you use the code blocks I gave you in the other topic. Binding to the SAP API via that method means referencing a connection and session index. That index is generated at the time of creation by the code block and is not directly linked to the index maintained by the SAP GUI. I have struggled to explain this in person to developers within my group, so I apologize for the confusion. The best way I can explain it is with an example.   1. Bot opens the first session of SAP ses[0] 2. Bot opens second session of SAP ses[1] 3. Bot opens a third session of SAP ses[2] 4. Code block generates index and assigns ses[0] = 0;  ses[1] = 1; ses[2] = 2 5. Bot closes SAP ses[1] 6.Code block is re-run and generates a new index and assigns ses[0] = 0; ses[2] = 1   Since the relationship between the SAP ses[n] and the code block session index can quickly diverge, you will need to spend time developing a method to translate between the two. This is fairly easy to do.   Regards, Ian  

SasiAnbalagan
Level 4
Thanks Ian, I figured this out after I posted this, I have made this work. Thanks for your time and help.