Using the LOOP Statement 

Screen Painter

The LOOP...ENDLOOP screen command lets you perform looping operations in the flow logic. You can use this statement to loop through both table controls and step loops. Between a LOOP and its ENDLOOP, you can use the FIELD, MODULE, SELECT, VALUES and CHAIN screen keywords. Most often, you use the MODULE statement to call an ABAP module.

You must code a LOOP statement in both the PBO and PAI events for each table in your screen. This is because the LOOP statement causes the screen fields to be copied back and forth between the ABAP program and the screen field. For this reason, at least an empty LOOP...ENDLOOP must be there.

There are two important forms of the LOOP statement:

This statement loops through screen table rows, transferring the data in each block to and from the corresponding ABAP fields in your program. The screen table fields may be declared in ABAP as anything (database table, structure or individual fields) except as internal table fields.

With step loops, if you are implementing your own scrolling (for example, with F21 - F24 ) you must use this statement.

This statement loops through an internal table and the screen table rows in parallel. The screen table fields often are, but need not be, declared as internal table fields.

With this LOOP, step loop displays appears with scroll bars. This scrolling is handled automatically by the system.

For more details on the different LOOP statements, see:

Looping Directly Through a Screen Table

Looping Through an Internal Table