SapGuiGetCollection Function

Action

This function reads the return value of a previous SapGuiInvokeMethod call and provides it as a collection iterator.

The returned collection iterator has to be released after usage by calling SapGuiIteratorRelease.

Include file

SapGui.bdh

Syntax

SapGuiGetCollection( inout nIterator : number ) : boolean;
Parameter Description
nIterator This parameter will be assigned the collection iterator.

Return value

  • true if successful
  • false otherwise

Example

transaction TMain
  var
    sConnID   : string;
    i         : number;
    nIterator : number;
    nType     : number;
    nObject   : number;
    bRet      : boolean;
    sStr1, sStr2 : string;
  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", ""); 
  
    // SAP Easy Access
    ThinkTime(9.9);
    SapGuiSetActiveWindow("wnd[0]", "SAP Easy Access", SAPGUI_MATCH_Exact);

    SapGuiGetProperty("wnd[0]", "Children");
    SapGuiGetCollection(nIterator); 
  
    // nIterator now contains the iterator which the SapGuiGetProperty() call returned

    // Code using the iterator
    i := SapGuiIteratorGetCount(nIterator);
  while (SapGuiIteratorHasMore(nIterator)) do
    SapGuiIteratorFetchNext(nIterator);
    SapGuiIteratorGetObject(nIterator, nObject);
    sStr1 := "";
    sStr2 := "";
    SapGuiObjectGetType(nObject, sStr1, sStr2);
    SapGuiObjectFree(nObject);
    Print(sStr1 + " " + sStr2);
  end;

    SapGuiIteratorRelease(nIterator); // necessary to avoid a resource leak
  end TMain;