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.

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 ""

Example:
CallVB aufnr = guinet.GridControl.GetSelectedValue

 

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.

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:=

Example:
CallVB guinet.GridControl.GetSelectedRows colIs:="EQUNR,EQKTX" delimiter:=" "
Message "&text[_grid_selected_values]"
Message "&text[_grid_selected_rows]"


 

GridControl.GetRowCount
Returns the number of rows in the grid control
In an InputScript, this function can be used synchronously via CallVB.

CallVB x = guinet.GridControl.GetRowCount

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
Number of rows in the grid

Example:
CallVBAsync  rowcount = guinet.GridControl.GetRowCount

 

GridControl.GetColumnCount
Returns the number of columns in the grid control
In an InputScript, this function can be used synchronously via CallVB.

CallVB x = guinet.GridControl.GetColumnCount

Parameters
1 gridNo   Default: 1

Number of the grid on screen

Returns
Number of columns in the grid

Example:
CallVBAsync  colcount = guinet.GridControl.GetcolumnCount

 

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.

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

Examples:
CallVBAsync  colname = guinet.GridControl.GetColumnName 10

Returns "string|TPLNR|Functional location" in transaction IW38, standard view, where | denotes the tab character.


CallVBAsync  colname = guinet.GridControl.GetColumnName 5

Returns "date|GSTRP|Bsc start"

The column title may depend on the column width. For example,

CallVBAsync  colname = guinet.GridControl.GetColumnName 5

returns "date|GSTRP|Basic start date" if the column width is large enough.

To split the string into its individual components, you can use the CopyText statement. Example:

Set text[temp] "&V[colname]"
CopyText toString="colid" fromText="temp" line=2 delimiter="&V[_tabcharacter]"

Result: colid = GSTRP

GridControl.SelectRow
Selects a row with a given number

CallVBAsync guinet.GridControl.SelectRow  row

Parameters
1 row
Row number to select. It must be between 1 and the total grid row count.

2 gridNo   Default: 1
Number of the grid on screen

3 gridVew   Default: Nothing
Can be used from VB.NET if you already have the object pointer for the control

4 addSelection   Default: ""
If "X", the selected row is added to the already selected rows

5 removeSelection   Default: ""
If "X", the selected row is removed from the already selected rows

 

Returns
"X" if row was selected, "" otherwise

Example:
CallVBAsync guinet.GridControl.SelectRow  1


GridControl.SelectRowByValue
Selects the first row containing a given value

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
T
he 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

Example:
CallVBAsync guinet.GridControl.SelectRowByValue "PALO ALTO" column:="VARIANT"

GridControl.SelectAllRows
Selects all rows

CallVBAsync guinet.GridControl.SelectAllRows

Parameters
1 gridNo   Default: 1
Number of the grid on screen; needed 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
"X" if grid control was found, "" otherwise

Example:
CallVBAsync guinet.GridControl.SelectAllRows gridNo:="2"

 

GridControl.SelectColumn
Selects a column

CallVBAsync guinet.GridControl.SelectColumn 

In an InputScript this function can be used synchronously via CallVB.

Parameters
1 colid
The internal name of the column or the column number

2 gridNo   Default: 1
Number of the grid on screen

3 gridView   Default: Nothing
Can be used from VB.NET if you already have the object pointer for the control

4 addSelection   Default: ""
If "X", the selected column is added to the already selected columns

Returns
"X" if the column was selected, "" otherwise

Example:
CallVBAsync guinet.GridControl.SelectColumn  "KTEXT"

 

 

GridControl.SelectCell
Selects a cell

CallVBAsync guinet.GridControl.SelectCell  row column

Parameters
1
row
Row number to select. It must be between 1 and the total grid row count.

2 column
The internal name of a column, or the column number

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
"X" if value was found, "" otherwise

Example:
CallVBAsync guinet.GridControl.SelectCell 2 column:="VARIANT"

 

 

GridControl.ClickCell
Clicks a cell

CallVBAsync guinet.GridControl.ClickCell  row column

Parameters
1
row
Row number to select. It must be between 1 and the total grid row count.

2 column
The internal name of a column, or the column number

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
"X" if value was found, "" otherwise

Example:
CallVBAsync guinet.GridControl.ClickCell 2 column:="VARIANT"

 

GridControl.DoubleclickCell
Doubleclicks a cell

CallVBAsync guinet.GridControl.DoubleclickCell  row column

Parameters
1
row
Row number to select. It must be between 1 and the total grid row count.

2 column
The internal name of a column, or the column number

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
"X" if value was found, "" otherwise

Example:
CallVBAsync guinet.GridControl.DoubleclickCell 2 column:="VARIANT"

 

GridControl.ClickCellButton
Clicks a button in a cell

CallVBAsync guinet.GridControl.ClickCell  row column

Parameters
1
row
Row number to select. It must be between 1 and the total grid row count.

2 column
The internal name of a column, or the column number

3 gridNo   Default: 1
Number of the grid on screen

Returns
"X" if value was found, "" otherwise

Example:
CallVBAsync guinet.GridControl.ClickCellButton 2 column:="SELECT"

 

 

GridControl.ClickCurrentCell
Clicks the currently selected cell

CallVBAsync guinet.GridControl.ClickCurrentCell  

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
"X" if the grid was found, "" otherwise

Example:
CallVBAsync guinet.GridControl.ClickCurrentCell

 

 

GridControl.DoubleclickCurrentCell
Doubleclicks the currently selected cell

CallVBAsync guinet.GridControl.DOubleclickCurrentCell  

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
"X" if the grid was found, "" otherwise

Example:
CallVBAsync guinet.GridControl.DoubleclickCurrentell

 

 

 

GridControl.SelectCellByValue
Selects the first cell containing a given value

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

Example:
CallVBAsync guinet.GridControl.SelectCellByValue "PALO ALTO" _
        column:=
"VARIANT"  rowSelection:="X"

 

GridControl.ClickCellByValue
Clicks on the first cell containing a given value

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

Example:
CallVBAsync guinet.GridControl.ClickCellByValue "PALO ALTO" column:="VARIANT" 

 

 

GridControl.DoubleclickCellByValue
Doubleclicks on the first cell containing a given value

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

Example:
CallVBAsync guinet.GridControl.DoubleclickCellByValue "PALO ALTO" _ column:="VARIANT" 

 

GridControl.GetCellValue
Reads the cell content
Attention: Needs to be called up asynchronously to work in large grids, see remarks below

CallVBAsync guinet.GridControl.GetCellValue row colid

Parameters
1 row
The row number

Remark:
rowno
if 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:
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:

// 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:

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:

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.

GridControl.SetCellValue
Sets the cell content

CallVBAsync guinet.GridControl.SetCellValue row column value

Parameters
1 row
The row number

2 column
The internal name of the column or the column number
 
3 value
The new cell content

4 gridNo   Default: 1

Number of the grid on screen

5 gridView   Default: Nothing
Can be used from VB.NET if you already have the object pointer for the control

Returns
"X" if the grid control was found, "" otherwise

Example:
CallVBAsync guinet.GridControl.SetCellValue  _
        
5  "AUFNR" "15634"

Remarks:
For some grid controls, depending on the implementatiion of the grid in ABAP, it may be necessary to add
  CallVBAsync guinet.GridControl.PressEnter  wait:="true" 
in the InputScript after the cell values have been set.

GridControl.PressEnter
Presses the Enter key within the grid control

CallVBAsync guinet.GridControl.PressEnter

Parameters
1 gridNo   Default: 1
Number of the grid on screen

2 wait   Default: false
Waits for the execution of the Enter key

Returns
"X" if the grid control was found, "" otherwise

Example:
CallVBAsync guinet.GridControl.PressEnter  wait:="true" 

 

Remarks:
For some grid controls, depending on the implementatiion of the grid in ABAP, it may be necessary to add
  CallVBAsync guinet.GridControl.PressEnter  wait:="true" 
in the InputScript after the cell values have been set.

GridControl.SetFocus
Sets the focus to the grid control

CallVBAsync guinet.GridControl.SetFocus

Parameters
1 gridNo   Default: 1
Number of the grid on screen

Returns
"X" if the grid control was found, "" otherwise

Example:
CallVBAsync guinet.GridControl.SetFocus 

 

GridControl.CopyText
Copies the whole grid (or selected columns) into a GuiXT text variable

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:
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.  

CallVBAsync guinet.GridControl.GridToTable tablename

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.      

Example:
CallVBAsync opcount = guinet.GridControl.GridToTable _
       tableName:=
"operations"
_
      
columns:="aufnr,ktext,vornr,ltxa1,v_arbpl:arbpl,v_sttxt:sttxt"

 

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.

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:
// Load all grid rows
Screen ...
  CallVBAsync guinet.GridControl.LoadAllRows
  Enter

Screen ...
  ...

GridControl.SetColumnWidth
Sets the
width of a column

CallVBAsync guinet.GridControl.SetColumnWidth colid width

Parameters
1 colId
The internal name of the column or the column number
 
2 width
The new column width

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
"X" if the gridcontrol and column was found, "" otherwise

Example:
CallVBAsync guinet.GridControl.SetColumnWidth "KTEXT" "50"

 

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.

CallVBAsync columnorder = guinet.GridControl.GetColumnOrder

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
A comma-separated list of the column names

 

GridControl.SetColumnOrder
Reorders the columns

CallVBAsync
guinet.GridControl.SetColumnOrder columns

Parameters
1 columns
Comma-separated list of the column names in the order in which they should be displayed

  • No additional columns can be added and no columns can be removed
  • Invalid column names are ignored
  • All existing columns not specified in the list are automatically appended in the order in which they are currently displayed

2 gridNo   Default: 1
Number of the grid on screen

3 gridView   Default: Nothing
Can be used from VB.NET if you already have the object pointer for the control

Returns
"X" if the gridcontrol was found and the columns could be reordered, "" otherwise

Example:
CallVBAsync guinet.GridControl.SetColumnOrder _  
       "PM_SELECTED,AUFNR,KTEXT,GSTRP,AUART"

 

Components
InputAssistant + Controls