Yesterday I discussed with a friend of mine about different methods of analyzing SAP GUI Scripting programs at runtime. One very easy method, to understand and to see where the attributes or methods are in the SAP GUI Scripting hierarchy, is the Visual Basic for Application (VBA) debugger and its watch window.
You can use VBA from a lot of applications, e.g. Microsoft Office Word or Excel. Press Alt+F11 to open the VBA IDE. At first you must choose the menu item Tools, References and search for the file C:\Program Files\SAP\FrontEnd\SAPgui\sapfewse.ocx, to bind the SAP GUI Scripting API to your VBA program.
Now you can use the following program to check the possibilities:
Option Explicit Sub Test() Dim SapGuiAuto As Object Dim Application As SAPFEWSELib.GuiApplication Dim Connection As SAPFEWSELib.GuiConnection Dim Session As SAPFEWSELib.GuiSession Dim Window As SAPFEWSELib.GuiModalWindow Dim Coll As SAPFEWSELib.GuiCollection Set SapGuiAuto = GetObject("SAPGUI") If Not IsObject(SapGuiAuto) Then Exit Sub End If Set Application = SapGuiAuto.GetScriptingEngine() If Not IsObject(Application) Then Exit Sub End If Set Connection = Application.Connections(0) If Not IsObject(Connection) Then Exit Sub End If Set Session = Connection.Sessions(0) If Not IsObject(Session) Then Exit Sub End If Set Window = Session.FindById("wnd") If IsObject(Window) Then Set Coll = Window.DumpState("") Stop End If Set Coll = Nothing Set Window = Nothing Set Session = Nothing Set Connection = Nothing Set Application = Nothing Set SapGuiAuto = Nothing End Sub
Execute it in debug mode with F5, it stops at line 35. Choose the variable Coll and add it to your watch window. Open the GuiCollection in the watch window and view the complete hierarchy of the object and the values of the attributes, like in the following picture.
The VBA debugger offers many possibilities to analyze SAP GUI Scripting objects at runtime.