Skip to content

Routine Declaration Hygiene (Top Placement & Order) ​

WarningClean ABAP & Modern Syntax#EC DEF_TOPRemote Enabled

Overview ​

Routine Declaration Hygiene (top placement & order).

ATC Finding Messages:

  • Reorder definitions to beginning of routine; avoid scattered declarations
  • Declare local TYPES before CONSTANTS before DATA before FIELD-SYMBOLS

Rationale ​

Declarations placed in the middle of executable code interrupt reading flow and conceal variable scope. Moreover, arbitrary ordering can place a DATA declaration before the TYPE it references. Maintain clean routine hygiene by placing all local declarations at the beginning of the routine in strict hierarchical order: TYPES before CONSTANTS before DATA before FIELD-SYMBOLS.

Non-Compliant ​

abap
METHOD process_order.
  lv_total = 100.
  DATA lv_tax TYPE i.
  FIELD-SYMBOLS <fs> TYPE i.
  TYPES ty_status TYPE c LENGTH 1.
ENDMETHOD.

Compliant ​

abap
METHOD process_order.
  TYPES ty_status TYPE c LENGTH 1.
  CONSTANTS lc_rate TYPE i VALUE 18.
  DATA lv_tax TYPE i.
  FIELD-SYMBOLS <fs> TYPE i.
  lv_total = 100.
ENDMETHOD.

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_DEF_TOPBooleantrueEnforce all local declarations (DATA, TYPES, CONSTANTS) at top of method body
CHECK_DECL_ORDERBooleantrueEnforce declaration order: TYPES first, then CONSTANTS, then DATA

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.