### SAP GUI Scripting API - Method and Property Examples Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/f4304b961f1d4527b738f14ee52cef6a_locale=en-US&state=PRODUCTION&version=800.08 Provides examples of setting properties like `Text`, `RecordMode`, and `TestToolMode`, and invoking methods like `Resize` and `getAbsoluteRow` with different parameter types. ```APIDOC ## SAP GUI Scripting API - Method and Property Examples ### Description This section demonstrates how to interact with SAP GUI elements by setting properties and invoking methods. Examples include setting text, controlling recording mode, and resizing UI elements, along with selecting rows in table controls. ### Examples: 1. **Setting the `Text` Property** * **Type**: "SP" * **Method/Property name**: `Text` * **Parameters**: "Hello World" * **Description**: Sets the `Text` property to the string "Hello World". 2. **Setting the `RecordMode` Property** * **Type**: "SP" * **Method/Property name**: `RecordMode` * **Parameters**: True * **Description**: Sets the `RecordMode` property to a Boolean value. The script generation should handle textual representations like "true", "True", or "TRUE". 3. **Setting the `TestToolMode` Property** * **Type**: "SP" * **Method/Property name**: `TestToolMode` * **Parameters**: 0 * **Description**: Sets the `TestToolMode` property to the integer value 0. 4. **Invoking the `Resize` Method** * **Type**: "M" * **Method/Property name**: `Resize` * **Parameters**: 9632False * **Description**: Calls the `Resize` method with three parameters. The third parameter is an array with 3 elements. 5. **Selecting a Row in a Table Control** * **Scenario**: Selecting a specific row in a table control and marking it as selected. * **Steps**: * Get the absolute row number. * Set the `selected` property to True. * **Generated Script Code**: ```javascript Session.findById("wnd[0]/usr/tblSAPMBIBSTC537").getAbsoluteRow("1").selected = "True" ``` * **Description**: This code snippet demonstrates how to select the first row (index "1") of the table control `SAPMBIBSTC537` and set its selected state to true. ``` -------------------------------- ### Start SAP Transaction (VBScript) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/a4e022f6c155414d9c8ae8eba422cac5_locale=en-US&state=PRODUCTION&version=800.08 The `StartTransaction` function initiates a specific SAP transaction. For example, calling `StartTransaction("xyz")` is equivalent to executing `SendCommand("/nxyz")`. ```VBScript Public Sub StartTransaction(ByVal Transaction As String) ' Implementation details for starting a transaction. End Sub ``` -------------------------------- ### Attach to Running SAP GUI Instance and Start Transaction (VBScript) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/a020c8f8cfaf48ec9b579d5961889639 Shows how to attach to an already running SAP GUI instance using the Running Object Table. It retrieves the application object, then accesses a specific connection and session to start a transaction by setting the text of an input field and sending a virtual key. This script is intended for VBScript environments. ```vbscript Rem Get the application object from the Running Object Table Set rotEntry = GetObject( "SAPGUI") Set application = rotEntry.GetScriptingEngine Rem Get the first session of the first connection Rem You may have to adjust this to access a different session Set connection = application.Children(0) Set session = connection.Children(0) Rem Start a transaction session.findById( "wnd[0]/tbar[0]/okcd").text = "/nbibs" session.findById( "wnd[0]").sendVKey 0 ``` -------------------------------- ### ABAP Message Call Example Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/d3fcc9198de14195bf2237d22dbcafad_locale=en-US&state=PRODUCTION&version=800.08 An example of an ABAP language line demonstrating a message call with parameters. This illustrates how parameters are passed and how they affect the property values. ```ABAP message e319(01) with 'test1' 'test2' 'test3' 'test4'. ``` -------------------------------- ### SAP GUI Session Transaction and Utility Functions Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/42892da4a05349ef90a12d5e82c894be Functions for starting transactions, sending virtual keys, and managing session-related utilities. ```APIDOC ## GuiDispIDSesStartT /GuiSession ### Description Starts a transaction in the SAP GUI session. ### Method POST (assumed) ### Endpoint /websites/help_sap_sap_gui_for_windows/GuiDispIDSesStartT ### Parameters #### Request Body - **transactionCode** (string) - Required - The transaction code to start. ### Request Example ```json { "transactionCode": "VA01" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ## GuiDispIDSesVKey /GuiFrameWindow ### Description Sends a virtual key to the GUI frame window. ### Method POST (assumed) ### Endpoint /websites/help_sap_sap_gui_for_windows/GuiDispIDSesVKey ### Parameters #### Request Body - **vKey** (integer) - Required - The virtual key code to send. ### Request Example ```json { "vKey": 13 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ## GuiDispIDSesVKeyDesc /GuiSession ### Description Retrieves the description for a given virtual key. ### Method GET (assumed) ### Endpoint /websites/help_sap_sap_gui_for_windows/GuiDispIDSesVKeyDesc ### Parameters #### Query Parameters - **vKey** (integer) - Required - The virtual key code. ### Request Example ``` /websites/help_sap_sap_gui_for_windows/GuiDispIDSesVKeyDesc?vKey=13 ``` ### Response #### Success Response (200) - **description** (string) - The description of the virtual key. #### Response Example ```json { "description": "Enter" } ``` ``` -------------------------------- ### Transaction Handling API Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/a4e022f6c155414d9c8ae8eba422cac5_locale=en-US&state=PRODUCTION&version=800.08 Provides a method to directly start SAP transactions. ```APIDOC ## StartTransaction ### Description Calling this function with parameter "xyz" has the same effect as SendCommand("/nxyz"). ### Method Public Sub ### Endpoint N/A (Client-side script method) ### Parameters #### Path Parameters - **Transaction** (String) - Required - The transaction code to start. ### Request Example ```vbscript StartTransaction("ME21N") ``` ### Response #### Success Response N/A (Starts transaction) #### Response Example N/A ``` -------------------------------- ### Get Selection Start Line - SAP GUI Scripting Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/9ff5eb87c5b94e00b3ba063ddb4e8843_locale=en-US&state=PRODUCTION&version=800.08 Retrieves the line number where the current text selection starts. This read-only property indicates the starting line of a selected text block. ```VBScript Public Property SelectionStartLine As Long ``` -------------------------------- ### GuiSession Object Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/a2e9357389334dc89eecc1fb13999ee3 Provides the context for user tasks and is the entry point for recording or playing back user actions. It extends GuiContainer. ```APIDOC ## GuiSession Object ### Description The GuiSession object represents the user's current working context within SAP GUI. It serves as the primary access point for applications that need to record or playback user interactions for a specific task. ### Inheritance Extends GuiContainer. ### Type Prefix ses ### Name 'ses' followed by the session number in square brackets (e.g., ses[1]). ``` -------------------------------- ### Get Selection Start Column - SAP GUI Scripting Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/9ff5eb87c5b94e00b3ba063ddb4e8843_locale=en-US&state=PRODUCTION&version=800.08 Retrieves the column number where the current text selection starts. This read-only property defines the starting column of a selected text range. ```VBScript Public Property SelectionStartColumn As Long ``` -------------------------------- ### GuiVComponent Object Methods Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/2e44c4f890524686977e9729565f7824 This section details the general methods available for GuiVComponent objects, such as dumping state, setting focus, and visualizing components. ```APIDOC ## GuiVComponent Object Methods ### Description Provides access to fundamental operations on GUI components, including state inspection and interaction. ### Methods - DumpState - SetFocus - Visualize ``` -------------------------------- ### DumpState Method Example (VBScript) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/26824bb464b045558bf5c71a617aa7fb_locale=en-US&state=PRODUCTION&version=800.08 Demonstrates how to use the DumpState method to retrieve the state of a SAP GUI component. It shows how to interpret the returned GuiCollection hierarchy, which can include property values, method calls, and return values. ```vbscript Dim objGuiVComponent ' Assuming objGuiVComponent is an instance of a GuiVComponent ' Example 1: Dump full state Dim stateCollectionFull Set stateCollectionFull = objGuiVComponent.DumpState("") ' Example 2: Dump state for a specific inner object (if supported) ' Dim stateCollectionInner ' Set stateCollectionInner = objGuiVComponent.DumpState("InnerObjectName") ' The returned stateCollectionFull and stateCollectionInner are GuiCollection objects ' You would typically iterate through these collections to process the dumped state. ``` -------------------------------- ### Get Structure Block Start Line (VBScript) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/06d283b024964f689fdf55ea1f2bd0d9 Returns the starting line number of the structure block relevant to the provided line number. For nested blocks, it returns the start line of the innermost block. Returns -1 if the line is not within a structure block. ```vbscript Public Function GetStructureBlockStartLine( ByVal Line As Long ) As Long ``` ``` -------------------------------- ### Visualize Method Example (VBScript) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/26824bb464b045558bf5c71a617aa7fb_locale=en-US&state=PRODUCTION&version=800.08 Shows how to use the Visualize method to display or hide a red frame around a SAP GUI component. This can be used for debugging or highlighting specific elements during scripting. ```vbscript Dim objGuiVComponent ' Assuming objGuiVComponent is an instance of a GuiVComponent ' Display a red frame around the component objGuiVComponent.Visualize True ' Remove the red frame ' objGuiVComponent.Visualize False ' To visualize an inner object (if supported): ' objGuiVComponent.Visualize True, "InnerObjectName" ``` -------------------------------- ### Get Structure Block Start Line Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/06d283b024964f689fdf55ea1f2bd0d9 Returns the start line number of the structure block relevant to the provided line number. If the line is within a nested block, the start line of the innermost block is returned. Returns -1 if the line is not within a structure block. ```APIDOC ## GET /websites/help_sap_sap_gui_for_windows/GetStructureBlockStartLine ### Description Returns the start line of the structure block relevant to the line number passed to the method. If the line resides within a nested block then the start line of the innermost block will be returned. If the line does not reside within a structure block at all then the method returns -1. ### Method GET ### Endpoint /websites/help_sap_sap_gui_for_windows/GetStructureBlockStartLine ### Parameters #### Query Parameters - **Line** (Long) - Required - The line number to check for a structure block. ### Response #### Success Response (200) - **return_value** (Long) - The start line number of the structure block, or -1 if not applicable. #### Response Example ```json { "return_value": 10 } ``` ``` -------------------------------- ### Get Column Position (VBScript) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/4af24c3281fb4d6a809e53238562d3b2_locale=en-US&state=PRODUCTION&version=800.08 Returns the screen position of a column, starting from 1. Throws an exception for invalid column inputs. ```vbscript Public Function GetColumnPosition( ByVal Column As String ) As Long ``` ``` -------------------------------- ### ContextMenu Method Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/4af24c3281fb4d6a809e53238562d3b2 Emulates the request for a context menu. ```APIDOC ## ContextMenu Method ### Description Calling `ContextMenu` emulates the context menu request. ### Method `Public Sub ContextMenu()` ### Endpoint N/A (Method of a GUI object) ``` -------------------------------- ### Get Structure Block Start Line (VBScript) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/06d283b024964f689fdf55ea1f2bd0d9_locale=en-US&state=PRODUCTION&version=800.08 Returns the starting line number of the structure block relevant to the provided line number. For nested blocks, it returns the start line of the innermost block. If the line is not within a structure block, it returns -1. This is useful for code folding and navigation. ```VBScript Public Function GetStructureBlockStartLine( ByVal Line As Long ) As Long ``` -------------------------------- ### Instantiate GuiApplication Object and Open Connection (VBScript) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/a020c8f8cfaf48ec9b579d5961889639 Demonstrates how to create a GuiApplication object using CreateObject and then open a connection to an SAP system. It includes steps for starting a transaction, waiting, and then shutting down the connection. This script is intended for VBScript environments. ```vbscript Rem Create the GuiApplication object Set Application = CreateObject( "Sapgui.ScriptingCtrl.1") Rem Open a connection in synchronous mode Set Connection = Application.OpenConnection( "U9C [PUBLIC]", True) Set Session = Connection.Children(0) Rem Do something: Either fill out the login screen Rem or in case of Single-Sign-On start a transaction. Session.SendCommand( "/nbibs") MsgBox "Waiting..." Rem Shutdown the connection Set Session = Nothing Connection.CloseSession( "ses[0]") Set Connection = Nothing Rem Wait a bit for the connection to be closed completely Wscript.Sleep 1000 Set Application = Nothing MsgBox "Done" ``` -------------------------------- ### Get Selection Start Index - SAP GUI Scripting Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/9ff5eb87c5b94e00b3ba063ddb4e8843_locale=en-US&state=PRODUCTION&version=800.08 Retrieves the absolute, zero-based character index of the starting point of a visually selected text range. This read-only property is crucial for defining the beginning of a selected text segment. ```VBScript Public Property SelectionIndexStart As Long ``` -------------------------------- ### SAP GUI Connection String Formats Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/5704456a1fbd43139311dab0e1175060 This section outlines the different ways to construct connection strings for SAP GUI, enabling connections via IP addresses, hostnames, SAP routers, message servers, and symbolic system names. ```APIDOC ## Connection Strings Connection strings are used to describe a connection address for an SAP system's application server. ### Simple Connection Strings * **Format**: `/H//S/` * **Description**: Connects directly to an IP address or hostname on a specified port. The default SAP application server port is 3200 + system number. * **Example**: `/H/192.168.1.100/S/3200` or `/H/sapserver.example.com/S/sapdpXYZ` (where XYZ is the SAP system ID). ### SAP Routers * **Format**: `...` * **Description**: Used in WAN environments to route connections through one or more SAP routers. Each router can have a password. * **Router Format**: `/H//S//P/` * **Example**: `/H/router1.example.com/S/3299/P/router_pwd/H/192.168.1.100/S/3200` ### Message Servers and Logon Groups * **Format**: `/M//S//G/` * **Description**: Connects to an SAP system via a message server, which handles load balancing across application servers within a specified logon group. * **Example**: `/M/msgserver.example.com/S/3600/G/PUBLIC` * **Combined with SAP Router**: `/H/router1.example.com/S/3299/M/msgserver.example.com/S/3600/G/PUBLIC` ### Symbolic System Names * **Format**: `/R//G/` * **Description**: The most user-friendly format, addressing the SAP system by its symbolic name (often the System ID) and a logon group. * **Example**: `/R/PRD/G/SALES` ``` -------------------------------- ### Get Column Position in SAP GUI for Windows Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/4af24c3281fb4d6a809e53238562d3b2 Returns the screen position of a column, starting from 1. Requires the column identifier as input. ```VBScript Public Function GetColumnPosition( ByVal Column As String ) As Long ``` -------------------------------- ### Get Row Size - SAP GUI Scripting Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/da14be14ef214e6587dc4df66b648fea Retrieves the size of a specified splitter row in percentage. The row index starts from 1. ```vbs Public Function GetRowSize( ByVal Id As Long _ ) As Long ``` ``` -------------------------------- ### SAP GUI Window Management Properties and Methods Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/42892da4a05349ef90a12d5e82c894be This section covers properties and methods for managing SAP GUI windows, including resizing, minimizing, maximizing, and closing. ```APIDOC ## SAP GUI Window Management Properties and Methods ### Description This section details properties and methods for managing SAP GUI windows, including their visibility, state (iconic, maximized, restored), and actions like closing, hard copying, and resizing. ### Method N/A (This is a documentation of properties and methods, not an API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) This section describes the properties and methods for SAP GUI window management. **GuiDispIDGWButtonB** (boolean) - Indicates if the button is visible. **GuiDispIDGWClose** (boolean) - Closes the window. **GuiDispIDGWCompBitmap** (object) - Component bitmap. **GuiDispIDGWGuiFocus** (boolean) - Indicates if the GUI has focus. **GuiDispIDGWHandle** (integer) - The handle of the window. **GuiDispIDGWHardCopy** (boolean) - Performs a hard copy of the window. **GuiDispIDGWHardCopyMem** (boolean) - Performs a hard copy to memory. **GuiDispIDGWIconic** (boolean) - Indicates if the window is iconic (minimized). **GuiDispIDGWIconify** (boolean) - Iconifies (minimizes) the window. **GuiDispIDGWIsPopupDialog** (boolean) - Indicates if the window is a popup dialog. **GuiDispIDGWJumpBackward** (boolean) - Jumps backward in the window history. **GuiDispIDGWJumpForward** (boolean) - Jumps forward in the window history. **GuiDispIDGWMaximize** (boolean) - Maximizes the window. **GuiDispIDGWPopupDialogText** (string) - Text for a popup dialog. **GuiDispIDGWRestore** (boolean) - Restores the window to its previous size. **GuiDispIDGWSpyMode** (boolean) - Enables element visualization mode. **GuiDispIDGWStatusB** (boolean) - Indicates if the status bar is visible. **GuiDispIDGWSysFocus** (boolean) - Indicates if the system has focus. **GuiDispIDGWTabBackward** (boolean) - Navigates backward through tabs. **GuiDispIDGWTabForward** (boolean) - Navigates forward through tabs. **GuiDispIDGWTitleB** (boolean) - Indicates if the title bar is visible. **GuiDispIDGWToolB** (boolean) - Indicates if the toolbar is visible. **GuiDispIDGWVKAllowed** (boolean) - Indicates if virtual keys are allowed. **GuiDispIDGWWPHeight** (integer) - The height of the working pane. **GuiDispIDGWWPMsgBox** (boolean) - Shows a message box. **GuiDispIDGWWPResize** (boolean) - Resizes the working pane. **GuiDispIDGWWPResizeEx** (boolean) - Resizes the working pane with extended options. **GuiDispIDGWWPWidth** (integer) - The width of the working pane. #### Response Example N/A ``` -------------------------------- ### Create New SAP GUI Session (VBScript) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/a4e022f6c155414d9c8ae8eba422cac5_locale=en-US&state=PRODUCTION&version=800.08 Opens a new SAP GUI session, similar to executing the "/o" command. This function is useful for managing multiple concurrent SAP sessions. ```VBScript Public Sub CreateSession() ``` ``` -------------------------------- ### Get Column Size - SAP GUI Scripting Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/da14be14ef214e6587dc4df66b648fea Retrieves the size of a specified splitter column in percentage. The column index starts from 1. ```vbs Public Function GetColSize( ByVal Id As Long _ ) As Long ``` ``` -------------------------------- ### GuiGraphAdapt Object Documentation Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/ae5e1e61f2764315a59404ea3b9b768f_locale=en-US&state=PRODUCTION&version=800.08 Documentation for the GuiGraphAdapt object, detailing its purpose, limitations, and available methods and properties. ```APIDOC ## GuiGraphAdapt Object ### Description For the graphic adapter control only basic members from GuiShell are available. Recording and playback is not possible. ### Remarks In addition to the new, activeX based controls SAP GUI also comes with a set of external graphics executables, for example to display a GANTT chart. These executables are not supported within the API. If during the execution of a script one of these executables is launched, then the script will be blocked. If you need to automate a process during which a graphics executable is displayed, then you need an automation tool then allows you to both manipulate SAP GUI using the Scripting API, and other Windows applications using native methods. ### Methods All methods of the GuiVComponent Object: * DumpState * SetFocus * Visualize All methods of the GuiContainer Object: * FindById All methods of the GuiVContainer Object: * FindAllByName * FindAllByNameEx * FindByName * FindByNameEx All methods of the GuiShell Object: * SelectContextMenuItem * SelectContextMenuItemByPosition * SelectContextMenuItemByText ### Properties All properties of the GuiComponent Object: * ContainerType * Id * Name * Parent * Type * TypeAsNumber All properties of the GuiVComponent Object: * AccLabelCollection * AccText * AccTextOnRequest * AccTooltip * Changeable * DefaultTooltip * Height * IconName * IsSymbolFont * Left * Modified * ParentFrame * ScreenLeft * ScreenTop * Text * Tooltip * Top * Width All properties of the GuiContainer Object: * Children All additional properties of the GuiShell Object: * AccDescription * DragDropSupported * Handle * OcxEvents * SubType ``` -------------------------------- ### Get SAP GUI Patchlevel Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/a020c8f8cfaf48ec9b579d5961889639 Retrieves the patchlevel of the SAP GUI installation. This read-only Long property indicates the specific patch applied to the SAP GUI. ```VBScript Public Property Patchlevel As Long ``` -------------------------------- ### Key Input and Message Box Methods Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/f3812bd3dfdf4f32ab62b30551d0ca68 Methods for sending virtual key presses and displaying message boxes. ```APIDOC ## SendVKey ### Description Executes a virtual key (VKey) on the window. ### Method `Public Sub SendVKey(ByVal VKey As Integer)` ### Endpoint N/A (Method of a window object) ### Parameters * **VKey** (Integer) - Required - The virtual key code to send. VKeys are defined in the menu painter. ### Request Example ```vbscript ' Assuming 'session' is a valid SAP GUI session object ' Example: Send F1 key (VKey code for F1 is typically 1) session.findById("wnd[0]").SendVKey 1 ``` ### Response #### Success Response None (Subroutine) #### Response Example N/A ``` ```APIDOC ## IsVKeyAllowed ### Description Checks if a virtual key (VKey) is currently allowed or available on the window. ### Method `Public Function IsVKeyAllowed(ByVal VKey As Integer) As Byte` ### Endpoint N/A (Method of a window object) ### Parameters * **VKey** (Integer) - Required - The virtual key code to check. ### Response #### Success Response (Byte) * **True** (or non-zero): The VKey is allowed. * **False** (or zero): The VKey is not allowed. #### Response Example ```vbscript ' Assuming 'session' is a valid SAP GUI session object Dim isAllowed ' Example: Check if F1 key is allowed (VKey code for F1 is typically 1) isAllowed = session.findById("wnd[0]").IsVKeyAllowed(1) If isAllowed Then MsgBox "F1 key is allowed." Else MsgBox "F1 key is not allowed." End If ``` ``` ```APIDOC ## ShowMessageBox ### Description Displays a modal message box to the user on the `GuiFrameWindow`. ### Method `Public Function ShowMessageBox(ByVal Title As String, ByVal Text As String, ByVal MsgIcon As Long, ByVal MsgType As Long) As Long` ### Endpoint N/A (Method of a window object) ### Parameters * **Title** (String) - Required - The text to display in the message box title bar. * **Text** (String) - Required - The main text content of the message box. * **MsgIcon** (Long) - Required - Specifies the icon to display (e.g., information, warning, error). Consult SAP documentation for specific values. * **MsgType** (Long) - Required - Specifies the type of message box buttons (e.g., OK, Yes/No). Consult SAP documentation for specific values. ### Request Example ```vbscript ' Assuming 'session' is a valid SAP GUI session object Dim result ' Example: Show an information message box with an OK button result = session.findById("wnd[0]").ShowMessageBox("Information", "Operation completed successfully.", 64, 0) ' 64 for Information icon, 0 for OK button If result = 0 Then ' Assuming 0 is the return value for OK MsgBox "User clicked OK." End If ``` ### Response #### Success Response (Long) Returns one of the `MESSAGE_RESULT_*` values, indicating the user's action (e.g., which button was clicked). Consult SAP documentation for specific return values. #### Response Example `0` (if the user clicks 'OK') ``` -------------------------------- ### Get Column Index from Name in SAP GUI for Windows Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/8f08be87b0194d9882d0382eae798617_locale=en-US&state=PRODUCTION&version=800.08 Returns the index (starting from 1) of a column in the SAP GUI Tree Control, given its name. Requires the column key. ```vbscript Public Function GetColumnIndexFromName( ByVal Key As String ) As Long End Function ``` -------------------------------- ### Translate Virtual Key Code to Description (VBScript) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/a4e022f6c155414d9c8ae8eba422cac5_locale=en-US&state=PRODUCTION&version=800.08 The `getVKeyDescription` method translates numerical virtual key codes, often found in recorded scripts (e.g., `sendVKey(0)`), into human-readable text representations. For instance, the code `0` is converted to the string "Enter". ```VBScript Public Function getVKeyDescription(ByVal n as Integer) As String ' Implementation details for translation would go here. ' Example: If n = 0 Then getVKeyDescription = "Enter" Else getVKeyDescription = "Unknown Key" End If End Function ``` -------------------------------- ### Get Hierarchy Level in SAP GUI for Windows Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/8f08be87b0194d9882d0382eae798617_locale=en-US&state=PRODUCTION&version=800.08 Returns the hierarchy level of a specified node key in the SAP GUI Tree Control, starting from level 0. Requires the node key. ```vbscript Public Function GetHierarchyLevel( ByVal Key As String ) As Long End Function ``` -------------------------------- ### GuiComponent Object Properties Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/2e44c4f890524686977e9729565f7824_locale=en-US&state=PRODUCTION&version=800.08 This section lists the general properties available for any GuiComponent object. ```APIDOC ## GuiComponent Object Properties ### Description General properties applicable to all GuiComponent objects. ### Properties - **ContainerType** (Type) - Description - **Id** (Type) - Description - **Name** (Type) - Description - **Parent** (Type) - Description - **Type** (Type) - Description - **TypeAsNumber** (Type) - Description ``` -------------------------------- ### GuiVComponent Methods Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/4af24c3281fb4d6a809e53238562d3b2 Methods available for GuiVComponent objects, including state manipulation and focus control. ```APIDOC ## GuiVComponent Methods ### Description Provides access to methods for interacting with GuiVComponent objects, such as dumping state, setting focus, and visualizing the component. ### Methods - **DumpState**: Dumps the current state of the component. - **SetFocus**: Sets the input focus to the component. - **Visualize**: Visualizes the component. ``` -------------------------------- ### Get ROT Entry for SAP GUI (JAWS Script) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/b7d0d8eed1c34997aa021db76173d5aa This example shows how to retrieve the ROT entry for SAP GUI and the Scripting Engine using the SapROTWr.SapROTWrapper object within a JAWS Script. ```Visual Basic Object Wrapper, Object RotSAPGUI, Object SAPGUI Let Wrapper = CreateObject ( "SapROTWr.SapROTWrapper") Let RotSAPGUI = Wrapper.GetROTEntry ( "SAPGUI") Let SAPGUI = RotSAPGUI.GetScriptingEngine ``` -------------------------------- ### Get Radio Button Group Members in SAP GUI Scripting Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/12c0aa53e9bc4912a6729683ac39ec8d_locale=en-US&state=PRODUCTION&version=800.08 The 'GroupMembers' property retrieves a collection of all GuiRadioButton objects belonging to the same group as the current radio button. This is useful for iterating through and interacting with all buttons in a group, for example, to display their text. ```VBScript Set GroupMembers = session.findById("wnd[0]/usr/radRB2").GroupMembers For Each GroupMember In GroupMembers MsgBox GroupMember.Text Next ``` -------------------------------- ### Get GuiDialogShell Title (VBScript) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/1a82055c70f544869b08af5c8afec0ae_locale=en-US&state=PRODUCTION&version=800.08 The Title property retrieves the title of the dialog window. This is a read-only property, meaning it can only be accessed to get its value and cannot be modified directly. ```VBScript Public Property Title As String ``` -------------------------------- ### GuiSession Object Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/a4e022f6c155414d9c8ae8eba422cac5_locale=en-US&state=PRODUCTION&version=800.08 The GuiSession object provides the context for user tasks within SAP GUI. It serves as the entry point for applications to record or play back user actions related to a specific task. GuiSession extends GuiContainer and is identified by 'ses' followed by the session number in square brackets. ```APIDOC ## GuiSession Object ### Description The GuiSession provides the context in which a user performs a certain task such as working with a transaction. It is therefore the access point for applications, which record a user’s actions regarding a specific task or play back those actions. GuiSession extends GuiContainer. The type prefix is ses, the name is ses plus the session number in square brackets. ### Remarks GuiSession is self-contained in that ids within the context of a session remain valid independently of other connections or sessions being open at the same time. Usually an external application will first determine with which session to interact. Once that is clear, the application will work more or less exclusively on that session. Traversing the object hierarchy from the GuiApplication to the user interface elements, it is the session among whose children the highest level visible objects can be found. In contrast to objects like buttons or text fields, the session remains valid until the corresponding main window has been closed, whereas buttons, for example, are destroyed during each server communication. ``` -------------------------------- ### Window Management Methods Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/f3812bd3dfdf4f32ab62b30551d0ca68 Methods for controlling the state and behavior of SAP GUI windows. ```APIDOC ## Close ### Description Attempts to close the window. Closing the last main window of a session will display a confirmation dialog. ### Method `Public Sub Close()` ### Endpoint N/A (Method of a window object) ### Parameters None ### Request Example ```vbscript ' Assuming 'session' is a valid SAP GUI session object session.findById("wnd[0]").Close ``` ### Response #### Success Response None (Subroutine) #### Response Example N/A ``` ```APIDOC ## Iconify ### Description Sets a window to the iconified state. Affects the main window and all modal windows. ### Method `Public Sub Iconify()` ### Endpoint N/A (Method of a window object) ### Parameters None ### Request Example ```vbscript ' Assuming 'session' is a valid SAP GUI session object session.findById("wnd[0]").Iconify ``` ### Response #### Success Response None (Subroutine) #### Response Example N/A ``` ```APIDOC ## Maximize ### Description Maximizes a window. Only the main window can be maximized; modal windows are unaffected. ### Method `Public Sub Maximize()` ### Endpoint N/A (Method of a window object) ### Parameters None ### Request Example ```vbscript ' Assuming 'session' is a valid SAP GUI session object session.findById("wnd[0]").Maximize ``` ### Response #### Success Response None (Subroutine) #### Response Example N/A ``` ```APIDOC ## Restore ### Description Restores a window from its iconified state. Affects the main window and all modal windows. ### Method `Public Sub Restore()` ### Endpoint N/A (Method of a window object) ### Parameters None ### Request Example ```vbscript ' Assuming 'session' is a valid SAP GUI session object session.findById("wnd[0]").Restore ``` ### Response #### Success Response None (Subroutine) #### Response Example N/A ``` ```APIDOC ## JumpBackward ### Description Executes Ctrl+Shift+Tab on the window to move focus backward one block. ### Method `Public Sub JumpBackward()` ### Endpoint N/A (Method of a window object) ### Parameters None ### Request Example ```vbscript ' Assuming 'session' is a valid SAP GUI session object session.findById("wnd[0]").JumpBackward ``` ### Response #### Success Response None (Subroutine) #### Response Example N/A ``` ```APIDOC ## JumpForward ### Description Executes Ctrl+Tab on the window to move focus forward one block. ### Method `Public Sub JumpForward()` ### Endpoint N/A (Method of a window object) ### Parameters None ### Request Example ```vbscript ' Assuming 'session' is a valid SAP GUI session object session.findById("wnd[0]").JumpForward ``` ### Response #### Success Response None (Subroutine) #### Response Example N/A ``` -------------------------------- ### Navigate Backward with TabBackward Method Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/f3812bd3dfdf4f32ab62b30551d0ca68 The TabBackward method simulates pressing Shift+Tab to move focus backward one element in the SAP GUI window. It does not take any parameters and operates on the current window context. ```VBScript Public Sub TabBackward() End Sub ``` -------------------------------- ### GuiVComponent Object Properties Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/2e44c4f890524686977e9729565f7824_locale=en-US&state=PRODUCTION&version=800.08 This section lists the properties specific to GuiVComponent objects, which are visual components. ```APIDOC ## GuiVComponent Object Properties ### Description Properties specific to visual components (GuiVComponent objects). ### Properties - **AccLabelCollection** (Type) - Description - **AccText** (Type) - Description - **AccTextOnRequest** (Type) - Description - **AccTooltip** (Type) - Description - **Changeable** (Type) - Description - **DefaultTooltip** (Type) - Description - **Height** (Type) - Description - **IconName** (Type) - Description - **IsSymbolFont** (Type) - Description - **Left** (Type) - Description - **Modified** (Type) - Description - **ParentFrame** (Type) - Description - **ScreenLeft** (Type) - Description - **ScreenTop** (Type) - Description - **Text** (Type) - Description - **Tooltip** (Type) - Description - **Top** (Type) - Description - **Width** (Type) - Description ``` -------------------------------- ### Get ROT Entry and Session Info (Yahoo Widget) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/b7d0d8eed1c34997aa021db76173d5aa This snippet illustrates how to use the SapROTWr.SapROTWrapper object in a Yahoo Widget to get the SAP GUI Scripting Engine, open a connection, and retrieve information about the first session. ```Visual Basic var Wrapper = COM.createObject("SapROTWr.SapROTWrapper"); var SapGuiAuto = Wrapper.GetROTEntry( "SAPGUI"); var GuiApplication = SapGuiAuto.GetScriptingEngine(); var GuiConnection = GuiApplication.OpenConnection( "My System" ); var AllSessions = GuiConnection.Children; var GuiSession = AllSessions.ElementAt(0); alert( "Session: " + GuiSession.Id); ``` -------------------------------- ### Find GUI Element by Screen Position (VBScript) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/a4e022f6c155414d9c8ae8eba422cac5_locale=en-US&state=PRODUCTION&version=800.08 Performs a hittest on an SAP GUI session to find a component at specified screen coordinates (x, y). If no component is found and 'Raise' is not set to False, an exception is thrown. ```VBScript Public Function FindByPosition( ByVal x As Long, ByVal y As Long, Optional ByVal Raise As Variant _ ) As GuiCollection ``` ``` -------------------------------- ### SAP GUI Scripting: Submit HTML Form via GET (VBScript) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/611012b34e2b4843adba09f63fe3f866 This VBScript function submits an HTML form to the backend using the HTTP GET method. Data is appended to the event name in the URL, and the PostData parameter is left empty. ```VBScript sapEvent("Frame1","", "sapevent:SUBMIT_FORM_AS_GET_METHOD?FirstName=John&LastName=Smith") ``` -------------------------------- ### Navigate Forward with TabForward Method Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/f3812bd3dfdf4f32ab62b30551d0ca68 The TabForward method simulates pressing the Tab key to move focus forward one element in the SAP GUI window. It does not take any parameters and operates on the current window context. ```VBScript Public Sub TabForward() End Sub ``` -------------------------------- ### Get Node Properties and Navigation (SAP GUI Scripting) Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/8f08be87b0194d9882d0382eae798617_locale=en-US&state=PRODUCTION&version=800.08 These VBScript functions allow retrieval of various properties for nodes within a tree control, such as their count, dimensions, position, and text. They also facilitate navigation by providing methods to get parent, next, and previous node keys, as well as keys and text by path. ```VBScript Public Function GetListTreeNodeItemCount( ByVal NodeKey As String _ ) As Long ```  | Returns the number of visible items of the specified node for a list tree. `GetNextNodeKey```` Public Function GetNextNodeKey( ByVal NodeKey As String _ ) As String ```  | Returns the key of the next node belonging to the same node one level above. `GetNodeAbapImage```` Public Function GetNodeAbapImage( ByVal Key As String _ ) As String ```  | Retrieves the icon code of an image displayed in the specified node (for example “01”). `GetNodeChildrenCount```` Public Function GetNodeChildrenCount( ByVal Key As String _ ) As Long ```  | Returns the number of visible direct children of the specified node. `GetNodeChildrenCountByPath```` Public Function GetNodeChildrenCountByPath( ByVal Path As String _ ) As Long ```  | This function returns the number of visible children of the node given by the path parameter. `GetNodeHeight```` Public Function GetNodeHeight( ByVal Key As String _ ) As Long ```  | Returns the height of the specified node in pixels. `GetNodeIndex```` Public Function GetNodeIndex( ByVal Key As String _ ) As Long ```  | Returns the index of the specified key within its node. `GetNodeItemHeaders```` Public Function GetNodeItemHeaders( ByVal NodeKey As String _ ) As Object ```  | This method can only be used on trees of type 2 (Column Tree). It returns a collection of the texts belonging to the subnodes of the specified node in the hierarchy header column. `GetNodeKeyByPath```` Public Function GetNodeKeyByPath( ByVal Path As String _ ) As String ```  | Key of the node specified by the given path description. `GetNodeLeft```` Public Function GetNodeLeft( ByVal Key As String _ ) As Long ```  | Returns the left position of the specified node in pixels. `GetNodePathByKey```` Public Function GetNodePathByKey( ByVal Key As String _ ) As String ```  | Given a node key, the path is retrieved (e.g. 2\1\2). `GetNodesCol```` Public Function GetNodesCol() As Object ```  | The collection contains the node keys of all the nodes in the tree. `GetNodeStyle```` Public Function GetNodeStyle( ByVal NodeKey As String _ ) As Long ```  | Retrieves the index of the style assigned to the specified node. `GetNodeTextByKey```` Public Function GetNodeTextByKey( ByVal Path As String _ ) As String ```  | This function returns the text of the node specified by the given key. `GetNodeTextByPath```` Public Function GetNodeTextByPath( ByVal Path As String _ ) As String ```  | The text of a node defined by the given path is returned. `GetNodeTextColor```` Public Function GetNodeTextColor( ByVal Key As String _ ) As ULong ```  | Returns the font color of the specified node. `GetNodeToolTip```` Public Function GetNodeToolTip( ByVal NodeKey As String _ ) As String ```  | Returns the tooltip of the specified node. `GetNodeTop```` Public Function GetNodeTop( ByVal Key As String _ ) As Long ```  | Returns the top position of the specified node in pixels. `GetNodeWidth```` Public Function GetNodeWidth( ByVal Key As String _ ) As Long ```  | Returns the width of the specified node in pixels. `GetParent```` Public Function GetParent( ByVal CKey As String _ ) As String ```  | Key of the parent node of the node specified by the given key. `GetPreviousNodeKey```` Public Function GetPreviousNodeKey( ByVal NodeKey As String _ ``` -------------------------------- ### GuiGraphAdapt Object Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/a2e9357389334dc89eecc1fb13999ee3 Provides basic members from GuiShell for the graphic adapter control, but does not support recording or playback. ```APIDOC ## GuiGraphAdapt Object ### Description For the graphic adapter control, only fundamental members inherited from GuiShell are accessible. Recording and playback functionalities are not supported for this object. ### Method N/A (Object Description) ### Endpoint N/A (Object Description) ### Parameters N/A (Object Description) ### Request Example N/A (Object Description) ### Response #### Success Response (200) N/A (Object Description) #### Response Example N/A (Object Description) ``` -------------------------------- ### TabBackward Method Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/f3812bd3dfdf4f32ab62b30551d0ca68_locale=en-US&state=PRODUCTION&version=800.08 Executes the Shift+Tab key combination to navigate backward through elements in the SAP GUI window. ```APIDOC ## TabBackward ### Description Execute the Shift+Tab key on the window to jump backward one element. ### Method Public Sub TabBackward() ### Endpoint N/A (Method) ### Parameters None ### Request Example ```vbscript ' Example usage: ' session.findById("wnd[0]").TabBackward() ``` ### Response None ``` -------------------------------- ### SAP GUI Scripting API - Connection Strings Source: https://help.sap.com/docs/sap_gui_for_windows/b47d018c3b9b45e897faf66a6c0885a8/5704456a1fbd43139311dab0e1175060_locale=en-US&state=PRODUCTION&version=800.08 This section outlines the different ways to construct connection strings for the SAP GUI Scripting API, enabling connections to SAP systems via various methods. ```APIDOC ## SAP GUI Scripting API - Connection Strings ### Description Connection strings are used to define the address and parameters for connecting to an SAP system. The SAP GUI Scripting API supports several formats for these connection strings. ### Connection String Formats #### 1. Simple Connection Strings * **Purpose**: Direct TCP connection to an application server. * **Format**: `/H//S/` * `/H/`: Prefix for Host (IP address or hostname). * `/S/`: Prefix for Service (port number). The default SAP application server port is 3200 + SAP System Number. * **Example**: `/H/192.168.1.100/S/3201` or `/H/sapserver.example.com/S/sapdp01` #### 2. SAP Routers * **Purpose**: Connect to remote SAP systems through one or more SAP routers, often used in WAN environments. * **Format**: `...` * Each router is specified by its connection string, optionally followed by `/P/`. * **Example**: `/H/router1.example.com/S/3299/P/router_password/H/10.0.0.50/S/3200` #### 3. Message Servers and Logon Groups * **Purpose**: Connect to an SAP system using a message server for load balancing across application servers within a logon group. * **Format**: `/M//S//G/` * `/M/`: Prefix for Message Server Hostname. * `/S/`: Prefix for Message Server Port. * `/G/`: Prefix for Logon Group Name. * **Example**: `/M/msgserver.example.com/S/3600/G/PUBLIC` * **Note**: Can be combined with SAP Routers: `/M//S//G/` #### 4. Symbolic System Names * **Purpose**: Connect to an SAP system using its symbolic name (System ID) and a logon group. * **Format**: `/R//G/` * `/R/`: Prefix for Symbolic SAP System Name (System ID). * `/G/`: Prefix for Logon Group Name. * **Example**: `/R/PRD/G/SALES` ### Notes * Hostnames and symbolic service names require correct DNS and service configuration on the client. * SAP router passwords provide access control. * Message server connections require network access to the message server at the time of resolution. ```