Skip to content

Avoid CHECK Statements ​

WarningAnti-Patterns & Bad PracticesQuickFix Ready#EC NO_CHECK_IN_LOOPRemote Enabled

Overview ​

Avoid CHECK statements; prefer IF with RETURN or CONTINUE.

ATC Finding Messages:

  • Avoid CHECK inside loop; use IF ... CONTINUE instead
  • Avoid CHECK outside loop; use IF ... RETURN instead

Rationale ​

CHECK behaves like CONTINUE inside a loop but like RETURN outside a loop, so moving the statement between contexts silently changes control flow. That dual meaning makes refactoring and reviews hazardous. Replace it with an explicit IF ... CONTINUE or IF ... RETURN that states the intended behavior.

Non-Compliant ​

abap
LOOP AT lt_orders INTO ls_order.
  CHECK ls_order-status = 'OPEN'.
  process_order( ls_order ).
ENDLOOP.

Compliant ​

abap
LOOP AT lt_orders INTO ls_order.
  IF ls_order-status <> 'OPEN'.
    CONTINUE.
  ENDIF.
  process_order( ls_order ).
ENDLOOP.

Automated QuickFix ​

This rule provides an automated QuickFix directly in Eclipse ABAP Development Tools (ADT):

  1. Position the cursor on the flagged statement.
  2. Press Ctrl + 1 (Quick Assist).
  3. Select the automated refactoring to apply the clean syntax immediately.

Configuration & Thresholds ​

This check can be fine-tuned directly in the ATC Check Variant Editor (CHKV) in Eclipse ADT:

Parameter NameData TypeDefault ValueDescription & Guidance
CHECK_IN_LOOPBooleantrueDetect CHECK inside loops and suggest IF NOT ... CONTINUE guard clause
CHECK_OUTSIDE_LOOPBooleantrueDetect CHECK outside loops and suggest IF NOT ... RETURN guard clause

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.