SAP MDG · VALIDATION DERIVATION

How do I implement message severity adjustment in CHECK_ENTITY using ZMDG_MSG_CTRL in SAP MDG?

Use a post-processing method like ADJUST_MESSAGES to read the current MDG change-request context, match each ET_MESSAGE row against a control table such as ZMDG_MSG_CTRL, rewrite MSGTY when the rule matches, and delete messages that end up with initial type. Keep CHECK_ENTITY focused on collecting messages, then normalize them centrally.

Use a post-processing method like ADJUST_MESSAGES to read the current MDG change-request context, match each ET_MESSAGE row against a control table such as ZMDG_MSG_CTRL, rewrite MSGTY when the rule matches, and delete messages that end up with initial type. Keep CHECK_ENTITY focused on collecting messages, then normalize them centrally.

In SAP MDG, the clean pattern is to keep CHECK_ENTITY focused on building messages and then normalize them in a separate method like ADJUST_MESSAGES. The sample logic reads the current change-request context, checks the control table ZMDG_MSG_CTRL against step, CR type, CR status, message ID/number, and BU_GROUP, then rewrites MSGTY and removes messages that no longer have a valid type.

Process flow

  1. Open SE18 and verify the BAdI definition and interface.
  2. Create or edit the BAdI implementation in SE19.
  3. Assign or create the implementing class and activate it.
  4. Implement validation in CHECK_ENTITY and build ET_MESSAGE with message IDs, numbers, and field navigation.
  5. Implement a post-processing method like ADJUST_MESSAGES to read CR context and control-table rules.
  6. Match ET_MESSAGE against ZMDG_MSG_CTRL and rewrite MSGTY as needed.
  7. Delete messages whose MSGTY becomes initial.
  8. Test with a change request that matches each control-table scenario.

Referenced tables

ObjectPurpose
ZMDG_MSG_CTRLCustom control table used to decide how ET_MESSAGE severities are rewritten by step, CR type, CR status, message ID/number, and BU_GROUP.
USMD120CStandard MDG change-request status table used to derive the current CR status before message adjustment.

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

1method ADJUST_MESSAGES. 2 DATA: 3 lo_app_context TYPE REF TO if_usmd_app_context. 4 5 lo_app_context = cl_usmd_app_context=>get_context( ). 6 CHECK lo_app_context IS BOUND. 7 8 lo_app_context->get_attributes( 9 IMPORTING 10 ev_crequest_step = DATA(lv_crstep) 11 ev_crequest_type = DATA(lv_crtype) 12 ev_crequest_id = DATA(lv_cr_number) ). 13 14 CALL METHOD zcl_mdg_suppl_utility=>get_single_attribute 15 EXPORTING 16 im_crnumber = cr_number 17 im_field = 'BU_GROUP' 18 IMPORTING 19 ex_value = DATA(lv_bu_group). 20 21 SELECT SINGLE usmd_creq_status 22 FROM usmd120c 23 INTO @DATA(cr_status) 24 WHERE usmd_crequest = @cr_number. 25 26 SELECT * 27 INTO TABLE @DATA(lt_msg_ctrl) 28 FROM zmdg_msg_ctrl. 29 30 IF sy-subrc = 0. 31 LOOP AT ct_message ASSIGNING FIELD-SYMBOL(<fs_message>). 32 DATA(lv_msg) TYPE t100-text. 33 34 CALL FUNCTION 'FORMAT_MESSAGE' 35 EXPORTING 36 id = <fs_message>-msgid 37 lang = 'E' 38 no = <fs_message>-msgno 39 v1 = <fs_message>-msgv1 40 v2 = <fs_message>-msgv2 41 v3 = <fs_message>-msgv3 42 v4 = <fs_message>-msgv4 43 IMPORTING 44 msg = lv_msg 45 EXCEPTIONS 46 not_found = 1 47 others = 2. 48 49 LOOP AT lt_msg_ctrl INTO DATA(ls_msg_ctrl) 50 WHERE ( step = lv_crstep OR step = '' ) 51 AND ( usmd_creq_type = lv_crtype OR usmd_creq_type = '' ) 52 AND ( usmd_creq_status = cr_status OR usmd_creq_status = '' ) 53 AND ( msgid = <fs_message>-msgid OR msgid = '' ) 54 AND ( msgno = <fs_message>-msgno OR msgno = '' ) 55 AND ( bu_group = lv_bu_group OR bu_group = '' ). 56 IF lv_msg CP ls_msg_ctrl-message OR ls_msg_ctrl-message = ''. 57 <fs_message>-msgty = ls_msg_ctrl-msgty. 58 ENDIF. 59 ENDLOOP. 60 ENDLOOP. 61 62 DELETE ct_message WHERE msgty IS INITIAL. 63 ENDIF. 64 endmethod.

The remaining configuration, implementation details, and testing guidance continue from this answer more…

Related questions and keywords

Alternative questions

  • How can I control CHECK_ENTITY message types dynamically in MDG?
  • How do I rewrite validation messages in USMD_RULE_SERVICE based on CR step and type?
  • How do I use a custom control table to adjust MDG validation message severities?

Possible questions

  • What is the ABAP logic behind ADJUST_MESSAGES in MDG?
  • How do I filter validation messages by change request step and business partner group?
  • Which table can I use to control MDG message severity by CR context?
  • How do I enrich and normalize ET_MESSAGE in CHECK_ENTITY?
  • How do I implement a BAdI validation that changes message type from E to W?

Keywords

SAP MDGUSMD_RULE_SERVICECHECK_ENTITYADJUST_MESSAGESZMDG_MSG_CTRLET_MESSAGEmessage severitychange request stepBU_GROUPIF_EX_USMD_RULE_SERVICE