SapGuiInvokeMethod Function

Action

This function can be used to call any method exposed by SapGui controls. It is a low level function and has to be used together with SapGuiSet* functions. These SapGuiSet* functions are used to push parameters on the callstack for the method to be executed by SapGuiInvokeMethod.

Include file

SapGui.bdh

Syntax

SapGuiInvokeMethod( in sControlId  : string allownull, 
                    in sMethodName : string,
                    in sTimer      : string optional ) : boolean;
Parameter Description
sControlId This parameter uniquely identifies a SapGui control. The second parameter specifies the name of the method to be called on this control.
sMethodName The name of the method to be called on the control.
sTimer Name of the timer to be used for measurements.

Return value

  • true if successful
  • false otherwise

Example

transaction TMain
  var
  begin

    // Connecting to SAP
    gsConnID := SapGuiOpenConnection(" /SAP_CODEPAGE=1100 /FULLMENU 10.5.2.198 0 /3");
    SapGuiSetActiveConnection(gsConnID);
    SapGuiSetActiveSession("ses[0]");

    // SAP
    SapGuiSetActiveWindow("wnd[0]", "SAP", SAPGUI_MATCH_Exact);

    // maximize
    // wnd[0]
    SapGuiInvokeMethod("wnd[0]", "maximize");

    // Logon to SAP System
    // Before running a test you have to customize the password parameter!
    ThinkTime(3.1);
    SapGuiLogon("ddic", "*******", "000", "");

    // Copyright
    SapGuiSetActiveWindow("wnd[1]", "Copyright", SAPGUI_MATCH_Exact);

    // press
    // btn[0]
    SapGuiInvokeMethod("tbar[0]/btn[0]", "press");

    // SAP Easy Access
    ThinkTime(20.2);
    SapGuiSetActiveWindow("wnd[0]", "SAP Easy Access", SAPGUI_MATCH_Exact);

    // expandNode
    // shell
    SapGuiSetString("0000000003");
    SapGuiInvokeMethod("usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell", "expandNode");

    // selectedNode
    SapGuiSetProperty("usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell", "selectedNode", "0000000004");

    // topNode
    SapGuiSetProperty("usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell", "topNode", "Favo");

    // doubleClickNode
    // shell
    SapGuiSetString("0000000004");
    SapGuiInvokeMethod("usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell", "doubleClickNode");

    // press
    // btn[15]
    ThinkTime(20.6);
    SapGuiInvokeMethod("tbar[0]/btn[15]", "press");

    // press
    // btn[15]
    SapGuiInvokeMethod("tbar[0]/btn[15]", "press");

    // Log Off
    SapGuiSetActiveWindow("wnd[1]", "Log Off", SAPGUI_MATCH_Exact);

    // press
    // SPOP-OPTION1
    SapGuiInvokeMethod("usr/btnSPOP-OPTION1", "press");
  end TMain;