Prefer ICON_ Constants over Hardcoded Icon Codes
WarningClean ABAP & Modern Syntax#EC PREF_ICON_CONSTRemote Enabled
Overview
Prefer ICON_ constants over hardcoded icon codes.
ATC Finding Message:
Use icon_ constants instead of hardcoded icon codes
Rationale
SAP UI icons in dynpros, lists, and ALV grids are represented internally by 4-character codes enclosed in '@' symbols (such as '@01@'). Hardcoded string literals make code obscure and difficult to maintain. Clean ABAP requires using pre-defined system constants (such as icon_okay or icon_cancel from type pool ICON) instead of magic icon literals.
Non-Compliant
abap
lv_icon = '@01@'.Compliant
abap
lv_icon = icon_okay.Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC PREF_ICON_CONST
" SAP CI_ prefix format:
... "#EC CI_PREF_ICON_CONSTRelated Rules
- Avoid Magic Numbers; Use Named Constants —
#EC NO_MAGIC_NUMBERS - Avoid Repeating the Same String Literal —
#EC NO_DUP_LITERALS
Technical Details
- Native ATC Class:
ZCL_SKYLINT_PREF_ICON_CONST - Implementation File: zcl_skylint_pref_icon_const.clas.abap