Prefer Enumerations over Constants
WarningClean ABAP & Modern Syntax#EC PREF_ENUMRemote Enabled
Overview
Prefer ENUM over CONSTANTS for set of related values.
ATC Finding Message:
Prefer ENUM over CONSTANTS for set of related values
Rationale
Use TYPES: BEGIN OF ENUM ... END OF ENUM for related discrete value sets instead of structured CONSTANTS for type safety and modern syntax.
Non-Compliant
abap
CONSTANTS:
BEGIN OF c_status,
open TYPE string VALUE 'O',
END OF c_status.Compliant
abap
TYPES:
BEGIN OF ENUM ty_status,
open,
END OF ENUM ty_status.Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC PREF_ENUM
" SAP CI_ prefix format:
... "#EC CI_PREF_ENUMRelated Rules
- Avoid Magic Numbers; Use Named Constants —
#EC NO_MAGIC_NUMBERS - Avoid Hardcoding System & Tenant Environment Checks (sy-sysid, sy-mandt) —
#EC NO_HARDCODED_ENV
Technical Details
- Native ATC Class:
ZCL_SKYLINT_PREF_ENUM - Implementation File: zcl_skylint_pref_enum.clas.abap