Table Controls in the Flow Logic
Use
Table controls are processed in the flow logic using the step loop technique. Loops are executed in the dynpro flow logic, whereby data is passed, line for line, between the dynpro fields of the line and the fields of the same name in the ABAP program The relevant commands in the flow logic are:
LOOP ... WITH CONTROL ctrl.
...
ENDLOOP.
These statements must not be confused with the ABAP statements of the same name. Using the WITH CONTROL addition, the name of the table control that is processed is specified for each loop. Between LOOP and ENDLOOP, the other flow logic keywords FIELD, MODULE, SELECT, VALUES, and CHAIN can be used.
During the loops, the contents of the step loop are transported back and forth between identically named fields of the ABAP program and the dynpro. At least one empty LOOP must exist for every table control, both in the PBO and the PAI processing block. Table control fields defined with a dictionary reference must be declared in the ABAP program, as before, usi ng TABLES, as interface work areas.
Within the loops, two system fields are of importance.
-
sy-stepl contains the current line of the table control counted from the uppermost displayed line
-
sy-loopc contains the current number of table control rows on the screen
We distinguish between two loop techniques.
Loop Across the Rows of the Table Control
The commands in the flow logic are:
LOOP WITH CONTROL ctrl.
...
ENDLOOP.
These statements create a loop pass across the step loop rows displayed on the screen. For PAI, they pass the data of each group to the identically named fields of the ABAP program or, vice versa, for PBO from the ABAP program to the step loop fields. In the LOOP- ENDLOOP loop, modules can be called that process the passed data and at PBO time read it from an internal table or at PAI time import it into an internal table.
Parallel Loops Across Table Control and an Internal Table
The commands in the flow logic are:
LOOP AT itab [INTO wa] WITH CONTROL ctrl.
...
ENDLOOP.
This statement assigns an internal table itab of the ABAP program to the table control and triggers a parallel loop pass across the table control rows displayed on the screen and across the internal table itab. The additions INTO and WITH CONTROL are possible at PBO time, but not at PAI. The assignment of the loop to the table control takes place at PAI time across the internal table.
Using the INTO addition, the fields of the internal table itab are written to the work area wa at the PBO time and the content of wa is transported, line by line, to the identically named fields of the table control on the screen. If there is no INTO addition, an internal table with a header line must be used. Then the content of the header line is transported line by line to the identically named fields of the table control on the screen at PBO time. No module is required for filling the table control rows.
Conversely, at PAI time, the internal table rows are not automatically filled with the contents of the table control rows. Instead, a dialog module must be called within the loop that modifies the table.
Data Transport for Table Controls
If dynpros with table controls exist, the order of the data transport changes.
At PBO time, the transport of the table control fields from the ABAP program to the dynpro takes place after every loop pass in the flow logic. The remaining dynpros fields are filled, as usual, at the end of PBO processing.
At PAI time, first all the dynpro fields that do not belong to a table control and not listed in any FIELD statements are transported to identically named fields of the ABAP program. The contents of the table control fields are transported, row by ,at the beginning of the associated loop pass, to the identically named fields of the ABAP program. The fields that are listed in the FIELD statements are transported, as usual, directly from the corresponding FIELD statement.