Skip to content

Prefer RETURN over EXIT in Methods ​

WarningClean ABAP & Modern SyntaxQuickFix Ready#EC RETURNRemote Enabled

Overview ​

Prefer RETURN over EXIT outside loop constructs.

ATC Finding Message: Use RETURN instead of EXIT when leaving a procedure

Rationale ​

EXIT has loop-specific meaning and can leave a method at a point that is easy to overlook when the surrounding code changes. RETURN explicitly ends the current procedure and cannot be confused with loop control. Use RETURN for method exit and LEAVE LOOP or CONTINUE for loop control.

Non-Compliant ​

abap
IF is_invalid( ).
  EXIT.
ENDIF.
process( ).

Compliant ​

abap
IF is_invalid( ).
  RETURN.
ENDIF.
process( ).

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.

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.