Purpose With GetGridValues you can read cells in an SAP grid control.

An alternative - but more complicated - is to use SAP GUI Scripting. This requires the activation of  SAP GUI Scripting in the SAP profile which is not necessary with GetGridValues. Internally GuiXT uses the keyboard command "Ctrl+C" and then parses the resulting Windows Clipboard content and fills the GuiXT variables. The Windows Clipboard is saved and restored after executing the command. 

Example 1 GetGridValues selectedCells="gx"

The GuiXT variables V[gx.i.k] receive the content of the selected grid cells. Here i=1,2,3,... is the row number and k=1,2,3,... the column number.

Example 2 // InputScript
Enter
"/niw38"

Screen RIAUFK20.1000

// optionally: set parameters for selection

// start selection
Enter "/8"

Screen SAPLSLVC_FULLSCREEN.0500
GetGridValues -prepare
Enter "/5" -visible  // Select all

Screen SAPLSLVC_FULLSCREEN.0500
GetGridValues selectedCells="iw38grid" selectedRowCount="r"

// Test message
Message "&V[r] rows selected" -statusline

Enter "/N"

Format GetGridValues selectedCells="name"
Options
selectedRowCount= The number of selected rows is put into the given variable
 
-prepare If the grid offers a function to select all rows (Ctrl+A or function code  =&ALL or F5 ), all rows will be marked as "selected" but if there are lots of rows the cell content of the rows not yet visible remains empty. With -prepare GuiXT scrolls through the grid in order to have all cells loaded from the SAP application server.

If the grid control doesn't allow the selection of multiple rows you do not need
-prepare.

At least one
Screen command is necessary between GetGridValues -prepare and GetGridValues selectedCells=.

PlePlease add  -visible to Enter, otherwise SAP GUI may not load all lines..
&row and &col in
selectedCells=
You may  specify "&row" und "&col" in  selectedCells=. Example:

GetGridValues selectedCells="orders.cell.&col.&row"

The variable names are then built up as indicated, i.e.  &row and &col are replaced by the corresponding row and column numbers. This is useful when you use the variables in your own table, since with the standard notation selectedCells="orders.cell"  rows and columns would be interchanged.

Remarks
  • If the user has chosen his own layout for the grid, then  GetGridValues is not applicable without additional measures, since the grid can contain different columns from those you expect. You either need to ensure by organizational methods that a particular default layout is active (normally SAP standard layout), or you set a particular layout in your InputScript, e.g. in IW38 as selection parameter "Layout".
Components GuiXT + InputAssistant