Purpose
Read all grid rows

Solution
Use the predefined VB function
   guinet.GridControl.GridToTable

It copies the content of the grid cells 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. The columns to be read can be specified in guinet.GridControl.GridToTable, see the example below. 

An alternative way to read the grid content is
   guinet.GridControl.CopyText


which loads the whole grid content into a single GuiXT text variable, one line for each grid row. This is appropriate if you want to pass the grid content to other programs e.g. Excel or VB.NET functions.


Example

We display a list of service operations, shown in a grid control in transaction IW37N, in our own table control.
Without further logic this doesn't make much sense, but it can be the basis of an application which, for example, displays additional columns showing order confirmation data.


Selection criteria, e.g. date from ... to



Result table

 


Variables (GuiXT debug window)

 

GuiXT Script

PushButton (1,2) "Load operations" process="load_operations.txt"
InputField (1,28) "Date from" (1,42) name="opfrom" -date
InputField (1,56) "to" (1,60) name="opto" -date

if V[opcount>0]
 
Table (3,2) (32,135) name="operations" rows="&V[opcount]" _
       
fixedColumns=6 title="&V[opcount] operations selected"

    Column "Order" name="aufnr" size=8
   
Column "Description" name="ktext" size=40
   
Column "Operation" name="vornr" size=8
   
Column "Short text" name="ltxa1" size=40
   
Column "Workplace" name="arbpl" size=10
   
Column "Syst.State" name="sttxt" size=20

endif

InputScript  "load_operations.txt" 

// clear all table values
Clear V[operations.*]

// start transaction IW37N
Enter "/niw37n"

// Selection of Orders and Operations
Screen RI_ORDER_OPERATION_LIST.1000

  Title "Please wait... Reading operations"

  // Selection criteria
  Set F[Period] "&V[opfrom]"
  Set F[Period to] "&V[opto]"

  Enter "/8" // Execute

// List of Orders and Operations
Screen SAPLSLVC_FULLSCREEN.0500

  Title "Please wait... Reading operations"

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

  Enter

Screen SAPLSLVC_FULLSCREEN.0500
  Enter /n

 

GuiXT Script Editor Pro: Grid column names

 

Components
InputAssistant + Controls