Processing selected rows
When a user changes data in a model set, the corresponding table row is said to be selected for processing. More than one row can be selected in a single interaction. Before the TBDISPL service returns control to the dialog function, the CRP is positioned to the first of the selected rows. First means the row closest to the top of the table, not the row that was selected first. The other selected rows are called pending selected rows.
When the CRP is positioned at a selected row, the row is retrieved, meaning the values from that row are stored in the appropriate dialog variables. Then, all input fields in the selected model set on the display are stored in the corresponding dialog variables. The dialog function can then process the row in any manner it chooses. For example, the function can invoke the TBPUT service to update the row, or it can invoke the BROWSE service to examine a file specified in that row.
A call of the TBDISPL service is required to position the CRP to each pending selected row. For these calls, neither the PANEL nor MSG parameter should be specified.
The system variable ZTDSELS contains the number of selected rows. It can be tested by the dialog function or in the )PROC section of the table display panel to determine if any rows were selected. For example:
)PROC
. . . /* Process fixed portion fields */
IF (&ZTDSELS ¬= 0000) /* Any selected rows? */
. . . /* Process scrollable portion flds*/
)END
- 0000
- No selected rows
- 0001
- One selected row (now the current row)
- 0002
- Two selected rows, consisting of the current row and a pending selected row
- 0003
- Three selected rows, consisting of the current row and two pending selected rows
- ⋮
- n
n
selected rows, consisting of the current row andn-1
pending selected rows.
As TBDISPL is reinvoked without the PANEL and MSG parameters (to process any pending selected rows), ZTDSELS is decremented by one. An example is shown in Table 1.
DM Service | User Action | Value of ZTDSELS |
---|---|---|
TBDISPL TAB1 PANEL(PAN1) | Selects 3 rows | 0003 (current row plus two pending selected rows) |
TBDISPL TAB1 | None | 0002 (current row plus one pending selected row) |
TBDISPL TAB1 | None | 0001 (current row; no pending selected rows) |