Purpose
Scroll through a table.

On a screen with one or more table controls we want to read all lines of one of the tables, not just its visible part.

Solution
Use the commands GetTableAttribute and Enter scrollToLine=...  table=... in order to scroll through the whole table. 

The InputScript "table_to_file" (below) downloads a table from screen  to a file, scrolling through all lines.  It also demonstrates how InputScripts can be written in a quite general manner. You can use it in a screen of your choice, specifying the table name and up to 5 column names as "using" parameters.  Add more column names if needed, or your own logic for selecting a subset of the lines.

Example
In transaction VA03 we add a button which saves all order items to a file and opens this file immediately. We use a ".csv" file so that Excel (if installed on the PC) will open up.

 

 
Excel opens and displays all order items

 

GuiXT Script 

// add a button that downloads the order items to Excel
Pushbutton P[Display item details]+(0,54) "@J2@" _
       size=
(1,2) process=
"table_to_file.txt"
  using tabname = "All items"
  using fid1 = "Material"
  using fid2 = "Order quantity"
  using fid3 = "UN"
 
using fid4 = "Description"
 
using fid5 = "Net value"


InputScript
"table_to_file.txt"
 

// General script for table viewing / download
//
// Example how to use it:
//
// Pushbutton (toolbar) "Download table" _
// process="table_to_file.txt"
// using tabname = "All items"
// using fid1 = "Material"
// using fid2 = "Order quantity"
// using fid3 = "UN"
// using fid4 = "Description"
// using fid5 = "Net value"

Parameter filename "&%[TEMP]\guixttemp.&V[today_ymdhms].csv"
Parameter tabname Table
Parameter fid1 1
Parameter fid2 2
Parameter fid3 3
Parameter fid4 4
Parameter fid5 5

OpenFile "&U[filename]" -output -utf8 delimiter=";"

// Variables
Set V[absrow] 1 // Absolute row number
Set V[relrow] 1 // Relative row number

Screen *
GetTableAttribute T[&U[tabname]] _
firstVisibleRow=FVisRow _
lastVisibleRow=LVisRow _
lastRow=LastRow

// First row on screen?
if V[FVisRow=1]
  goto new_row
endif

// scroll to first line
Enter "/scrollToLine=1" table="T[&U[tabname]]"

label new_screen
Screen *
GetTableAttribute T[&U[tabname]] _
firstVisibleRow=FVisRow _
lastVisibleRow=LVisRow _
lastRow=LastRow

Set V[relrow] 1

label new_row

// end of table?
if V[absrow>&V[LastRow]]
 
goto end_of_table
endif

// end of screen?
if V[absrow>&V[LVisRow]]
 
Enter "/scrollToLine=&V[absrow]" table="T[&U[tabname]]"
 
goto new_screen
endif

Set V[C1] "&cell[&U[tabname],&U[fid1],&V[relrow]]"
Set V[C2] "&cell[&U[tabname],&U[fid2],&V[relrow]]"
Set V[C3] "&cell[&U[tabname],&U[fid3],&V[relrow]]"
Set V[C4] "&cell[&U[tabname],&U[fid4],&V[relrow]]"
Set V[C5] "&cell[&U[tabname],&U[fid5],&V[relrow]]"
AppendFile "&U[filename]" C1 C2 C3 C4 C5

Set V[absrow] &V[absrow] + 1
Set V[relrow] &V[relrow] + 1

goto new_row

label end_of_table
CloseFile "&U[filename]"

// Display file
Start "&U[filename]"

// Back to line 1
Enter "/scrollToLine=1" table="T[&U[tabname]]"

Leave

Components
InputAssistant