Skip to content

Prefer FINAL( ) over DATA( ) when the variable is never written again ​

WarningClean ABAP & Modern SyntaxQuickFix Ready#EC PREF_FINALRemote Enabled

Overview ​

Declare inline variables as FINAL when never written again.

ATC Finding Message: Inline variable is never written again; declare it with FINAL( )

Rationale ​

An inline variable that is assigned once and never changed should be declared FINAL so the compiler enforces immutability. This prevents accidental later writes and documents that the value is a constant for the rest of the method. Use FINAL( ) for single-assignment locals.

Non-Compliant ​

abap
DATA(lv_count) = lines( lt_items ).
process( lv_count ).

Compliant ​

abap
FINAL(lv_count) = lines( lt_items ).
process( lv_count ).

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 PREF_FINAL

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

Technical Details ​

Released under the MIT License.