Skip to content

Do Not CLEAR Variables Directly After Declaration ​

WarningAnti-Patterns & Bad PracticesQuickFix Ready#EC REDUNDANT_CLEARRemote Enabled

Overview ​

Do not CLEAR or FREE variables redundantly.

ATC Finding Messages:

  • Do not CLEAR or FREE variables after declaration; they are already initial
  • Variable is CLEARed or FREEd but never read again before procedure ends

Rationale ​

A newly declared variable already has its type-specific initial value, so CLEAR immediately after DATA is a no-op. It adds noise and suggests the declaration might not initialize the variable. Remove the CLEAR or initialize the variable when it is actually reused.

Non-Compliant ​

abap
DATA lt_items TYPE string_table.
CLEAR lt_items.

Compliant ​

abap
DATA lt_items TYPE string_table.

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 Value
CHECK_BEFORE_WRITEBooleantrue
CHECK_WITHOUT_READBooleantrue

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.