Purpose Use the built-in functions of the native
control interface for the Grid Control
For most tasks it is not advisable to
program your own VB functions that communicate with the special SAP
UI controls such as grid control or tree control. The SAP UI
controls are more complex than one might think, since they
handle user actions, read and write the SAP GUI datastream and
communicate with SAP application. So your VB function is player
number three or four in this system.
The following functions, built in into the GuiXT Controls
interface "guinet.dll", cover most of what is normally needed.Please observe:
All functions have obligatory
and optional parameters. We
suggest you use the "by name" calling for all optional
parameters.
All functions can either be called from your GuiXT script, in most cases with
CallVBAsync, or from your own VB.NET function. If you need to
evaluate the return code of the built-functions it is often more
practical to call up your own VB.NET function with
CallVBAsync and then call the built-in function from there.
GridControl.GetSelectedValue
Returns the value of the selected cell, or "" if no cell selected
In an InputScript this function can be used synchronously via CallVB.
It is useful at the beginning of an InputScript if you need the selected
cell value for further processing. See also the returned system
variables (below) that indicate the column and row of the cell selected by
the user.
GuiXT
CallVB guinet.GridControl.GetSelectedValue
Parameters 1 gridNo Default: 1
Number of the grid on screen; you need it if there are several grids.
2 gridView Default:
Nothing Can be used from VB.NET if you already have the object
pointer for the control
Returns The content of the selected
cell or "" if not found.
Sets system variables V[_grid_current_colid]
Internal column name of selected cell, or "" V[_grid_current_rowno]
Row number of selected cell, or 0 V[_grid_current_value]
Cell content (same as returned value), or ""
GridControl.GetSelectedRows
Returns the selected row numbers as a comma-separated list of row
numbers, e.g. "408,412,589". In addition, two GuiXT text variables
receive the row numbers and cell content of the selected rows. In
an InputScript this function can be used synchronously via CallVB.
GuiXT
CallVB guinet.GridControl.GetSelectedRows
Parameters 1
colIds Default: ""
Comma separated list of internal column names. The content of the given
columns is copied into the text variable text[_grid_selected_values]
2 gridNo Default: 1
Number of the grid on screen; you need it if there are several grids.
3 gridView Default:
Nothing Can be used from VB.NET if you already have the object
pointer for the control 4
delimiter Default:
"," The cell values are separated from each other by the given
string
Returns A list of the selected rows
(comma-separated list of row numbers)
Sets system variables text[_grid_selected_rows]
Contains the selected row numbers, one text line for one row number.
text[_grid_selected_values] Contains the
content of the cells of the selected rows, one text line for each row,
where the content of all columns specified by
colids:= is copied.
The cell values are separated from each other by a comma or, if
specified, by the given string delimiter:=
GridControl.GetColumnName Returns the type, internal name and title of a column in the grid control, separated by a tab character
In an InputScript, this function can be used synchronously via
CallVB.
GuiXT
CallVB colname = guinet.GridControl.GetColumnName
Parameters 1 colNo
Column number 1,2,...
2 gridNo Default: 1
Number of the grid on screen
Returns Column information: column type, name and title, separated from each other by a tab character
CallVBAsync guinet.GridControl.SelectRowByValue value
Parameters 1 value The value to search
2 column Default: ""
The internal name of a column, or a comma separated list of columns,
where the value is searched.
3 gridNo Default: 1
Number of the grid on screen; needed it if there are several grids.
4 gridView Default:
Nothing Can be used from VB.NET if you already have the object
pointer for the control
5
isRegex Default:
"" If "X", the value is interpreted as a regular expression.
It is checked whether a substring of the cell content corresponds to the
given regular expression.
6 ignoreCase Default: ""
If "X", the comparison is case-sensitive
7 addSelection Default:
"" If "X", the selected row is added to the already selected
rows
8 removeSelection Default:
"" If "X", the selected row is removed from the already
selected rows
Returns The index 1,2,3 of the row found, 0
if not found
Sets system variables
V[_grid_current_colid] Internal
column name of selected cell V[_grid_current_rowno]
Row number of selected cell V[_grid_current_value]
Cell content
CallVBAsync guinet.GridControl.SelectCellByValue value
Parameters 1
value
The value to search
2 column Default: "" The
internal name of a column, or a comma separated list of columns, where
the value is searched
3 gridNo Default: 1
Number of the grid on screen
4 gridView Default:
Nothing Can be used from VB.NET if you already have the object
pointer for the control
5
rowSelection Default:
"" If "X" also selects the row
6
isRegex Default:
"" If "X", the value is interpreted as a regular expression.
It is checked whether a substring of the cell content corresponds to the
given regular expression.
7 ignoreCase Default: ""
If "X", the comparison is case-sensitive
Returns "X" if value was found, ""
otherwise
Sets system variables
V[_grid_current_colid] Internal
column name of selected cell V[_grid_current_rowno]
Row number of selected cell V[_grid_current_value]
Cell content
CallVBAsync guinet.GridControl.ClickCellByValue value
Parameters 1
value
The value to search
2 column Default: "" The
internal name of a column, or a comma separated list of columns, where
the value is searched
3 gridNo Default: 1
Number of the grid on screen
4 gridView Default:
Nothing Can be used from VB.NET if you already have the object
pointer for the control
5
rowSelection Default:
"" If "X" also selects the row
6
isRegex Default:
"" If "X", the value is interpreted as a regular expression.
It is checked whether a substring of the cell content corresponds to the
given regular expression.
7 ignoreCase Default: ""
If "X", the comparison is case-sensitive
Returns "X" if value was found, ""
otherwise
Sets system variables
V[_grid_current_colid] Internal
column name of selected cell V[_grid_current_rowno]
Row number of selected cell V[_grid_current_value]
Cell content
CallVBAsync guinet.GridControl.DOubleclickCellByValue value
Parameters 1
value
The value to search
2 column Default: "" The
internal name of a column, or a comma separated list of columns, where
the value is searched
3 gridNo Default: 1
Number of the grid on screen
4 gridView Default:
Nothing Can be used from VB.NET if you already have the object
pointer for the control
5
rowSelection Default:
"" If "X" also selects the row
6
isRegex Default:
"" If "X", the value is interpreted as a regular expression.
It is checked whether a substring of the cell content corresponds to the
given regular expression.
7 ignoreCase Default: ""
If "X", the comparison is case-sensitive
Returns "X" if value was found, ""
otherwise
Sets system variables
V[_grid_current_colid] Internal
column name of selected cell V[_grid_current_rowno]
Row number of selected cell V[_grid_current_value]
Cell content
Remark: rownoif guinet.dll before 2022 Q4 2. Also possible after that for compatibility reasons.
2 colId
The internal name of the column 3 gridNo Default: 1
Number of the grid on screen
4 gridView Default:
Nothing Can be used from VB.NET if you already have the object
pointer for the control
Returns The cell content or "" if not
found
Example: GuiXT
CallVBAsync val = guinet.GridControl.GetCellValue _
5 "VARIANT"
Remarks Do not use this function synchronously with
CallVB unless you have loaded all grid rows before.
Asynchronous calls with
CallVBAsync load the given row automatically. For example,
the following InputScript does not set the variables beyond number 137:
/
GuiXT
/ get grid row count
CallVB rowcount = guinet.GridControl.GetRowCount
// clear variables
Clear V[equnr.*]
// Set all equipment numbers into GuiXT variables
Set V[k] 1
label next_row
if not V[k>&V[rowcount]]
CallVB V[equnr.&V[k]] = guinet.GridControl.GetCellValue &V[k] EQUNR
Set V[k] &V[k] + 1
goto next_row
endif
To correct this, you can first load all rows in a separate
Screen...Enter block:
GuiXT
Screen saplslvc_fullscreen.0500
// Load all rows
CallVBAsync guinet.GridControl.LoadAllRows
Enter
Screen saplslvc_fullscreen.0500
// get grid row count
CallVB rowcount = guinet.GridControl.GetRowCount
// clear variables
Clear V[equnr.*]
// Set all equipment numbers into GuiXT variables
Set V[k] 1
label next_row
if not V[k>&V[rowcount]]
CallVB V[equnr.&V[k]] = guinet.GridControl.GetCellValue &V[k] EQUNR
Set V[k] &V[k] + 1
goto next_row
endif
Enter
Alternatively, read the cells asynchronously:
GuiXT
Screen saplslvc_fullscreen.0500
// get grid row count
CallVB rowcount = guinet.GridControl.GetRowCount
// clear variables
Clear V[equnr.*]
// Set all equipment numbers into GuiXT variables
Set V[k] 1
label next_row
if not V[k>&V[rowcount]]
CallVBAsync V[equnr.&V[k]] = guinet.GridControl.GetCellValue &V[k] EQUNR
Set V[k] &V[k] + 1
goto next_row
endif
Enter
Both methods work. An even better alternative is to use
guinet.GridControl.GridToTable
or guinet.GridControl.CopyText
if you need to obtain the content of all grid rows.
The
"lazy grid loading" effect does not show up when you read
rows selected by the user, since the content of these rows is already
loaded.
Parameters 1 gridNo Default: 1
Number of the grid on screen
Returns "X" if the grid control was
found, "" otherwise
Example: GuiXT
CallVBAsync guinet.GridControl.SetFocus
GridControl.CopyText
Copies the whole grid (or selected columns) into a GuiXT text variable
GuiXT
CallVBAsync guinet.GridControl.CopyText
Parameters 1
textName Default: ""
Name of the text variable
2
columns Default:
"*" Comma separated list of internal column names to be
copied. Default "*" means: all columns 3 delimiter Default: TAB character (Hex code 09)
Delimiter (string is possible) to be used between the returned cell
values
4 replaceDelimiter Default:
" " If the delimiter is part of a cell value, it will be
replaed by the given character or string 5 header Default:
" " If "X", the first line returned contains the internal
column names 6 gridNo Default: 1
Number of the grid on screen
7 gridView Default:
Nothing Can be used from VB.NET if you already have the object
pointer for the control
Returns The same text that is put into
the text variable. If you cannot be sure that it is a very small grid,
use the text variable instead of the returned value, since GuiXT
variables are limited to 4000 bytes in contrast to the text variables
which are not limited.
Example:
GuiXT
Screen ...
CallVBAsync guinet.GridControl.CopyText "equi" columns:="EQUNR,EQKTX"
Enter
Screen ...
CopyText fromText="equi" toFile="C:\temp\equi.txt"
Enter
GridControl.GridToTable
Copies the whole grid (or selected columns) into GuiXT variables,
using a separate variable name for each cell. The variable name
structure is like the one used for your own tables so that you can
immediately display the content in a table, or address each cell content
in your script.
Parameters 1
tableName
Used to build up the variable names
2
columns Default:
"*" Comma separated list of internal column names to be
copied. Default "*" means: all columns. For each grid
column name in the list you can specify a different column name in your
table. Separate the two names by ":", see the example below. 3 gridNo Default: 1
Number of the grid on screen
4 gridView Default:
Nothing Can be used from VB.NET if you already have the object
pointer for the control
5 selectedRows Default:
"" If "X", only the selected grid rows are returned
Returns Total row count of the grid
Sets variables
V[tablename.cell.colid.row]
where tablename is the given first parameter, colid the internal
name of the column (see parameter "columns", and row is the row number.
GridControl.LoadAllRows
Loads all grid rows from the SAP application server You need to
put this function into a separate Screen...Enter block. The
function is rarely needed, since the build-functions such as GridControl.SelectRowByValue
or GridControl.CopyText
already load the rows if necessary.
GuiXT
CallVBAsync guinet.GridControl.LoadAllRows
Parameters 1 gridNo Default: 1
Number of the grid on screen
2 gridView Default:
Nothing Can be used from VB.NET if you already have the object
pointer for the control
Returns The total number of grid rows
Example: GuiXT
// Load all grid rows
Screen ...
CallVBAsync guinet.GridControl.LoadAllRows
Enter
Screen ...
...
GridControl.GetColumnOrder
Returns a comma-separated list of the column names in the order in
which they are currently displayed In
an InputScript this function can be used synchronously via CallVB.