Skip to content

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_WHERE

Technical Details ​

Released under the MIT License.