Browsing Through Grids and Tables

Below are some examples of functions used for accessing the data in grid and table controls.

Grid Control

A grid control has columns and rows. A cell is identified by its row index and column name. To get the value of a cell you must specify the row index and the column name. The following sample shows you how to access all cells in a grid by iterating through all columns and rows.
SapGuiGridGetColumnCount("CTRLID", iColCount);
SapGuiGridGetRowCount("CTRLID ", iRowCount);
for rowix:=0 to iRowCount-1 do
for colix:=1 to iColCount do
SapGuiGridGetColumnName("CTRLID ", colix, colName);
SapGuiGridGetCellData("CTRLID ", rowix, colix,
cellValue);
end;
end;

Row indices are 0-based. Therefore, you iterate from rowix 0 to row count -1.

Table Control

The table control is similar to the grid control. A cell is identified by its row and column index. Both indices are 0-based. The following sample shows you how to access all cells in the table by iterating through all columns and rows.
SapGuiTableGetColumnCount("CTRLID", iColCount);
SapGuiTableGetRowCount("CTRLID ", iRowCount);
for rowix:=0 to iRowCount do
for colix:=1 to iColCount do
cellValue := SapGuiTableGetText("CTRLID ", rowix,
colix);
end;
end;