Skip to content

Avoid Loops That Execute At Most Once ​

WarningAnti-Patterns & Bad Practices#EC NO_SINGLE_ITERRemote Enabled

Overview ​

Avoid Loops That Execute At Most Once.

ATC Finding Message: Loop contains an unconditional EXIT or RETURN and executes at most once

Rationale ​

A loop statement (LOOP, WHILE, or DO) containing an unconditional EXIT or RETURN at its top nesting level will execute at most once. This usually indicates an algorithmic bug, a leftover prototyping construct, or the misuse of a loop instead of a conditional block or helper method.

Non-Compliant ​

abap
LOOP AT lt_items ASSIGNING <ls_item>.
  process( <ls_item> ).
  EXIT.
ENDLOOP.

Compliant ​

abap
IF line_exists( lt_items[ 1 ] ).
  process( lt_items[ 1 ] ).
ENDIF.

Suppression ​

To suppress findings for this rule, append the pseudo-comment to the statement:

abap
" Standard pseudo-comment:
... "#EC NO_SINGLE_ITER

" SAP CI_ prefix format:
... "#EC CI_NO_SINGLE_ITER

Technical Details ​

Released under the MIT License.