Skip to content

Redundant IF Condition Before LOOP AT ​

WarningClean ABAP & Modern Syntax#EC NO_LOOP_GUARDRemote Enabled✏️ Edit Rule on GitHub

Overview ​

Redundant IF condition before LOOP AT.

ATC Finding Message: Unnecessary IF guard before LOOP AT; an empty table iterates 0 times

Rationale ​

An internal table loop (LOOP AT itab) executes zero times when the internal table is empty. Wrapping the entire loop in an IF itab IS NOT INITIAL check adds unnecessary nesting and boilerplate code.

Non-Compliant ​

abap
IF lt_items IS NOT INITIAL.
  LOOP AT lt_items INTO DATA(ls_item).
    process_item( ls_item ).
  ENDLOOP.
ENDIF.

Compliant ​

abap
LOOP AT lt_items INTO DATA(ls_item).
  process_item( ls_item ).
ENDLOOP.

Suppression ​

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

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

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

Technical Details ​

Community & Feedback ​

Released under the MIT License.