This functions counts the number of columns of a SapGui grid control.
SapGui.bdh
SapGuiGridGetColumnCount( in     csControlId : string,
                          in out iCount      : number ) : boolean; 
               	 | Parameter | Description | 
|---|---|
| sControlId | The unique id of the grid | 
| iCount | The value to be assigned the number of columns. | 
true if successful
false otherwise
transaction TMain
  var
    iCount  : number;
    sConnID : string;
  begin
    // Connecting to SAP
    sConnID := SapGuiOpenConnection( " /SAP_CODEPAGE=1100 /FULLMENU 10.5.2.132 0 /3");
    SapGuiSetActiveConnection(sConnID);
    SapGuiSetActiveSession("ses[0]");
    // SAP
    SapGuiSetActiveWindow("wnd[0]", "SAP", SAPGUI_MATCH_ExactNoCase);
    SapGuiWindowAction(SAPGUI_WND_MAXIMIZE);
    SapGuiLogon("ddic", "*******", "000", "");
    SapGuiIgnoreError(SAPENGINE_STATUSBAR_CHANGED, SEVERITY_SUCCESS);
    SapGuiSetActiveWindow("wnd[0]", "SAP Easy Access", SAPGUI_MATCH_ExactNoCase);
    SapGuiSelectTopNode( "usr/cntlSINWP_CONTAINER/shellcont/shell/shellcont[0]/shell", "Workplace: DDIC", " 1", "TopNode\\Workplace: DDIC");
    ThinkTime(16.8);
    SapGuiGridSelectCell( "usr/cntlSINWP_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[0]/shell", 1, "OBJDES");
    SapGuiGridGetColumnCount( "usr/cntlSINWP_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[0]/shell" , iCount);
  end TMain;