Avoid Dynamic MESSAGE Statements
WarningClean ABAP & Modern Syntax#EC NO_DYN_MESSAGERemote Enabled
Overview
Avoid Dynamic MESSAGE Statements.
ATC Finding Message:
MESSAGE works with a dynamic operand - keep ID, TYPE and NUMBER static
Rationale
MESSAGE ... ID <dyn> TYPE <dyn> NUMBER <dyn> hides the message source: it cannot be found through a where-used search from SE91, defeats static analysis of message usage, and makes text and behavior depend on runtime values. Keep ID, TYPE and NUMBER static so the message is easy to find along the Clean ABAP Make messages easy to find guidance; inline-text MESSAGE forms are covered by pref-msg-cls.
Non-Compliant
abap
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 INTO lv_text.Compliant
abap
MESSAGE e001(msg_class)
WITH sy-msgv1 sy-msgv2 INTO lv_text.Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC NO_DYN_MESSAGE
" SAP CI_ prefix format:
... "#EC CI_NO_DYN_MESSAGERelated Rules
- Use a message class (SE91) instead of inline message text —
#EC PREF_MSG_CLS - Avoid Obsolete MESSAGE ... RAISING in Methods —
#EC NO_MSG_RAISING - Avoid Unnecessary Dynamic Programming Constructs (SQL Injection Prevention) —
#EC NO_DYNAMIC_STMT
Technical Details
- Native ATC Class:
ZCL_SKYLINT_NO_DYN_MESSAGE - Implementation File: zcl_skylint_no_dyn_message.clas.abap