Prefer LOOP AT WHERE over IF CONTINUE Guards
WarningClean ABAP & Modern Syntax#EC PREF_LOOP_WHERERemote Enabled
Overview
Filter LOOP AT With a WHERE Clause.
ATC Finding Message:
Loop starts with an IF CONTINUE guard - filter rows with WHERE instead
Rationale
Filtering internal table rows with the WHERE clause of LOOP AT is more efficient and more readable than starting the loop with an initial IF ... CONTINUE guard. The ABAP runtime evaluates the WHERE condition directly during row traversal, skipping non-matching rows before the loop body executes. Clean ABAP (Tables section) recommends LOOP AT ... WHERE over nested filtering inside the loop body.
Non-Compliant
abap
LOOP AT lt_rows INTO ls_row.
IF ls_row-status <> 'X'.
CONTINUE.
ENDIF.
" loop body
ENDLOOP.Compliant
abap
LOOP AT lt_rows INTO ls_row WHERE status = 'X'.
" loop body
ENDLOOP.Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC PREF_LOOP_WHERE
" SAP CI_ prefix format:
... "#EC CI_PREF_LOOP_WHERERelated Rules
- Merge Nested IF Statements —
#EC PREF_MERGE_IFS - Avoid Redundant CONTINUE at End of Loop —
#EC NO_USELESS_CONT - Modernize READ TABLE (Table Expressions & line_exists) —
#EC PREF_TAB_EXPR
Technical Details
- Native ATC Class:
ZCL_SKYLINT_PREF_LOOP_WHERE - Implementation File: zcl_skylint_pref_loop_where.clas.abap