Entering content frame

Table Controls in the Flow Logic Locate the document in its SAP Library structure

Processing table controls in the flow logic takes place with the so-called steploop technique. Loops are executed in the screen flow logic, whereby data is passed, line for line, between the screen fields of the line and the same-name fields 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 names. Using the WITH CONTROLaddition, the name of the table control that is processed is specified for each loop. Between LOOP and ENDLOOP, you can use the other flow logic keywords FIELD, MODULE, SELECT, VALUES, and CHAIN.

During the loops, the contents of the step loop are transported back and forth between identically-named fields of the ABAP program and the screen. At least one empty LOOP must exist for every table control, both in the PBO and the PAI processing block. Note that table control fields defined with Dictionary reference must be declared in the ABAP program, as before, with TABLES as interface work areas.

Within the loops, two system fields are of importance.

·        sy-steplcontains the current line of the table control counted from the uppermost displayed line

·        sy-loopccontains the current number of table control rows on the screen

We differentiate between two loop techniques.

Loop Through the Rows of the Table Control

The commands in the flow logic are:

LOOP WITH CONTROL ctrl.
  ...
ENDLOOP.

These statements create a loop pass through the step loop rows displayed on the screen. For PAI, they transfer the data of each group into the identically-named fields of the ABAP program or, vice versa, for PBO from the ABAP program into the step loop fields. In the LOOP-ENDLOOP loop, you can call modules that process the transferred data and for PBO read from an internal table, or for PAI import into an internal table.

Parallel Loops Through 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 run over the table control rows displayed on the screen and over the internal table itab. The additions INTO and WITH CONTROL are possible at the time of PBO, but not at PAI. The assignment of the loop to the table control takes place at PAI through the internal table.

Using the INTO addition, the fields of the internal table itab are written to the work area wa at the time of PBO and the content of wa is transported, line by line, to the identically-named fields of the table control on the screen. Without the INTO addition, you must use an internal table with a header line. 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 the time of PBO. No module is required for filling the table control rows.

Conversely, at the time of PAI, the internal table rows are not automatically filled with the contents of the table control rows. Instead, you must call a dialog module within the loop that modifies the table.

Data Transport for Table Controls

If you have screens with table controls, the sequence of the data transport changes.

At the time of PBO, the transport of the table control fields from the ABAP program to the screen takes place after every loop run in the flow logic. The remaining screen fields are filled, as usual, at the end of PBO processing.

At PAI time, first all the screen fields that do not belong to any table control and not listed in any FIELDstatement are transported to identically-named fields of the ABAP program. The contents of the table control fields are transported, row by row at the beginning of the corresponding loop run, into the identically-names fields of the ABAP program. The fields that are listed in the FIELDstatements are transported, as usual, directly from the corresponding FIELDstatement.

 

Leaving content frame