SAP NetWeaver AS ABAP Release 752, ©Copyright 2017 SAP AG. All rights reserved.
ABAP - Keyword Documentation → ABAP - Reference → Processing Internal Data → Internal Tables → Processing Statements for Internal Tables →
LOOP AT itab
Syntax Forms
Loop across table rows
1. LOOP AT itab
result [cond].
...
ENDLOOP.
Loop across row groups
2. LOOP AT itab
result [
cond] GROUP BY group_key
[ASCENDING|DESCENDING [AS TEXT]]
[WITHOUT MEMBERS]
[group_result].
...
ENDLOOP.
Effect
Executes a table iteration as a loop across an internal table itab. itab is a functional operand position.
The statements LOOP and ENDLOOP define the statement block of the loop. The statement LOOP reads rows from the internal table itab sequentially that meet an optional condition cond.
To exit processing of the statement block, the statements described in the leave loops section can be used.
Note
Internal tables can also be specified as a data source of a query in Open SQL.
Example
Simple 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 ).