Skip to content

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_MESSAGE

Technical Details ​

Released under the MIT License.