Purpose
Query selected grid rows

Solution
Use the predefined VB function
   guinet.GridControl.
GetSelectedRows

It returns the selected row numbers as a comma-separated list of row numbers, e.g. "408,412,589". In addition,  two GuiXT text variables are filled:

  • text[_grid_selected_rows] also contains the selected row numbers, one text line for one row number.
  • text[_grid_selected_values] is filled with the content of the cells of the selected rows, one text line for each row, where the content of all columns specified with colids:= is copied. The cell values are separated from each other by a comma or, if specified, by the given string delimiter:=


Example

In transaction IW37N we add a button "Lock selected orders". Before locking the orders we display a warning message which contains the order numbers and the short text for each order selected.


IW37N, warning message before locking the selected orders


GuiXT Script

Pushbutton (toolbar) "Lock selected orders" process="lock_orders.txt"

InputScript  "lock_orders.txt" 

// -----------------------------
// lock selected orders in IW37N
// ------------------------------

Screen saplslvc_fullscreen.0500

  // collect selected rows
  CallVBAsync selrows = guinet.GridControl.GetSelectedRows _
     colids:="AUFNR,KTEXT" delimiter:=
" "

  Enter

Screen saplslvc_fullscreen.0500

 // any rows selected? else no action
  if not V[selrows]
    Message "W: No rows selected" -statusline
   
Enter
    Leave
  endif

  Set text[msg] "Do you want to lock the following orders:\n\n"
  CopyText fromText="_grid_selected_values" toText="msg" -appendline

 // display warning message
  Message "&text[msg]" -yesno title="Lock orders"

 // continue? else no action
  if not Q[ok]
    Enter
    Leave
  endif

 // Process detail screen for each order
  Enter "=IOBJ"

label next_order
Screen saplcoih.3000

 // display title during processing
  Title "Please wait... Locking order &F[CAUFVD-AUFNR.2] &F[CAUFVD-KTEXT]"

 // lock the order
  Enter "=SPER"

 goto next_order

Components
InputAssistant + Controls