LOOP AT itab
7.31 | 7.40 | 7.54
Loop across table rows
1. LOOP AT itab result [cond].
Loop across row groups
2. LOOP AT itab result [ cond] GROUP BY group_key
[ASCENDING|DESCENDING [AS TEXT]]
ENDLOOP define the statement
block of the loop. The statement
LOOP reads rows from the internal table
itab sequentially that meet an optional condition
If the addition
GROUP BYis not specified, the statement block is executed for each read row and the row can be processed here. The way in which the read row is addressed in the statement block is specified in the output behavior
GROUP BYis used to group the read rows by a group key group_key and the statement block is then executed for every group. The way in which the current group is addressed in the statement block is specified in the output behavior
To exit processing of the statement block, the statements described in the leave loops section can be used.
LOOP over an internal table.
DATA itab TYPE TABLE OF i WITH EMPTY KEY. itab = VALUE #( FOR i = 1 UNTIL i > 10 ( i ) ). DATA(str) = ``. LOOP AT itab ASSIGNING FIELD-SYMBOL(<fs>). str = str && CONV string( <fs> ) && ` `. ENDLOOP. cl_demo_output=>display( str ).