SAP LOOP AT ITAB VARIANTS ABAP Statements



Get Example source ABAP code based on a different SAP table
  


ID LOOP-ITAB
• LOOP AT itab ABAP Statement

LOOP AT itab
Short Reference

ABAP_SYNTAX_FORMS

Loop Across Table Lines
1 LOOP AT itab result $[ cond$].
...
ENDLOOP.


Loop Across Line Groups
2 LOOP AT itab result $[ cond$] GROUP BY group_key
$[ASCENDING$|DESCENDING $[AS TEXT$]$]
$[WITHOUT MEMBERS$]
$[ group_result$].
...
ENDLOOP.

What does it do?
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 lines from the internal table itab sequentially that meet an optional condition cond.
If the addition GROUP BY is not specified, the statement block is executed for each read line and the line can be processed here. The way in which the read line can be addressed in the statement block is specified in the output behavior result.
The addition GROUP BY is used to group the read lines by a group key group_key and the statement block is then executed for each group. The way in which the current group can be addressed in the statement block is specified in the output behavior group_result.
To exit processing of the loop, the following statements can be used: