SapGuiObjectInvokeMethod Function

Action

This functions invokes a method for the passed object. The parameter list has to be specified with prior calls of SapGuiObjectSet functions.

The return value of this function call can be fetched by calling one of the SapGuiObjectGet functions.

Include file

SapGui.bdh

Syntax

SapGuiObjectInvokeMethod( in nObject     : number,
                          in sMethodName : string ) : boolean;
Parameter Description
nObject The handle to the object.
sMethodName The method to be called.

Return value

  • true if successful
  • false otherwise

Example

transaction TMain
  var
    sVal      : string;
    sConnID   : string;
    i         : number;
    nIterator : number;
    nType     : number;
    nObject   : number;
    bRet      : boolean;
  begin

    // Connecting to SAP
    sConnID := SapGuiOpenConnection(" /SAP_CODEPAGE=1100 /FULLMENU 10.5.2.198 0 /3");
    SapGuiSetActiveConnection(sConnID);
    SapGuiSetActiveSession("ses[0]");
  
    // SAP
    SapGuiSetActiveWindow("wnd[0]", "SAP", SAPGUI_MATCH_Exact);
    SapGuiWindowAction(SAPGUI_WND_MAXIMIZE);
  
    // Logon to SAP System
    SapGuiIgnoreError(SAPENGINE_STATUSBAR_CHANGED, SEVERITY_SUCCESS);
    ThinkTime(2.8);
    SapGuiLogon("ddic", "minisap", "000", "");

    // Copyright
    ThinkTime(2.1);
    SapGuiSetActiveWindow("wnd[1]", "Copyright", SAPGUI_MATCH_Exact);
    SapGuiPressButton("tbar[0]/btn[0]");
  
    // SAP Easy Access
    ThinkTime(9.9);
    SapGuiSetActiveWindow("wnd[0]", "SAP Easy Access", SAPGUI_MATCH_Exact);
    SapGuiGetPropertyCollection("wnd[0]", "Children", nIterator);
  
    while (SapGuiIteratorHasMore(nIterator)) do
      SapGuiIteratorFetchNext(nIterator);
      SapGuiIteratorGetObject(nIterator, nObject);
      SapGuiObjectSetBoolean(nObject, true);
      SapGuiObjectInvokeMethod(nObject, "method");
      SapGuiObjectGetBoolean(nObject, bRet);
      SapGuiObjectFree(nObject);
      Print(string(bRet));
    end;
  
    SapGuiIteratorRelease(nIterator);
  end TMain;