Accessing Control Properties

The SAPGUI scripting interface offers the ability to access all controls on the current window. Each control has different properties that can be accessed with SapGuiGetProperty. As SAPGUI scripting is based on COM technology, there are many COM libraries that implement those COM objects. Those libraries also include type information for each control type.

To get a list of properties and methods of the different control types, you can view those libraries with a tool that allows COM type library inspection. OLEView32 is a tool that comes with Microsoft Visual Studio that can be used for this purpose.

The following libraries can be found in the SAP install directory (usually: C:\Program Files\SAP\Frontend):
  • SAPGUI\sapfewse.ocx

    This contains the basic controls (for example, text, button)

  • Controls\Scripting\*.dll

    This contains extended controls such as trees and grids

All object properties can be accessed with SapGuiGetProperty. For example:
SapGuiGetProperty("TXTCTRLID", "text", sTextValue);
When a property returns another SAPGUI object or SAPGUI collection, the returned object is stored internally and can be accessed with the constant value SAPGUI_ACTIVEOBJECT for any SapGui API call for the control ID parameter. For example:
SapGuiPressButton(SAP GUI_ACTIVEOBJECT);