SapGuiGridGetSelectedCells Function

Action

The collection of selected cells contains strings, each of which has the format “<index of the row>,<column identifier>”, such as “0,CARRID”.

Include file

SapGui.bdh

Syntax

SapGuiGridGetSelectedCells( in  sControlId : string allownull, 
                            out nIterator  : number ) : boolean;
Parameter Description
sControlId The controls’s unique id.
nIterator This parameter will be assigned the handle to the collection iterator.

Return value

  • true if successful

  • false otherwise

Example

transaction TMain
  var
    sConnID       : string;
    nIterator     : number;
    sSelectedCell : string;
    nType         : number;
  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);
    
    SapGuiGridGetSelectedCells("usr/tblRSDEMO02TC_COLS/txtDEMO_CPROP-GROUP4", nIterator);
    while SapGuiIteratorHasMore(nIterator) do
      SapGuiIteratorFetchNext(nIterator);
      SapGuiIteratorGetValue(nIterator, sSelectedCell, nType);
      Print(sSelectedCell);
    end;
  
    SapGuiIteratorRelease(nIterator);

  end TMain;