SAP MDG · VALIDATION DERIVATION
How do I populate ET_MESSAGE correctly in SAP MDG CHECK_ENTITY validation logic?
Use usmd_s_message rows for every validation failure, set MSGID/MSGNO/MSGTY and FIELDNAME, append to ET_MESSAGE, then optionally enrich row navigation and normalize severity after collecting all messages.
Use usmd_s_message rows for every validation failure, set MSGID/MSGNO/MSGTY and FIELDNAME, append to ET_MESSAGE, then optionally enrich row navigation and normalize severity after collecting all messages.
In SAP MDG `IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY`, validation messages should be returned in `ET_MESSAGE` as `usmd_s_message` rows, not raised as hard ABAP errors. The source pattern shows a reusable helper that appends an error row, appends whole message tables safely, enriches navigation with `ZCL_MDG_SUPPL_UTILITY=>GET_MESSAGE_ROW_ID`, and normalizes severity with `ZCL_MDGBP_BP_VALIDATION=>ADJUST_MESSAGES`.
Process flow
- Open `SE18` and inspect the BAdI definition `
USMD_RULE_SERVICE` and interface `IF_EX_USMD_RULE_SERVICE`. - Create or open the implementation in `SE19` and assign the implementing class.
- Implement `CHECK_ENTITY` with entity guards and dynamic field access using `ASSIGN COMPONENT`.
- Build `usmd_s_message` rows with `MSGID`, `MSGNO`, `MSGTY`, `FIELDNAME`, and optional variables.
- Append messages to `ET_MESSAGE`, or merge local tables with `APPEND LINES OF`.
- Call `ZCL_MDG_SUPPL_UTILITY=>GET_MESSAGE_ROW_ID` to enrich row navigation if required.
- Call `ZCL_MDGBP_BP_VALIDATION=>ADJUST_MESSAGES` if severity normalization is part of your process.
- Activate the class, BAdI implementation, and dependent message/helper objects in the correct order.
Referenced tables
| Object | Purpose |
|---|---|
usmd_t_message | Internal table type used to collect MDG validation messages. |
usmd_s_message | Single message row structure for `ET_MESSAGE` population. |
ILLUSTRATIVE ABAP SAMPLE
Reusable ET_MESSAGE helper pattern for MDG CHECK_ENTITY
Source-supported helper class that appends errors, merges message tables, enriches navigation, and normalizes severity.
1CLASS zcl_usmd_check_entity_skill DEFINITION
2 PUBLIC
3 FINAL
4 CREATE PUBLIC.
5
6 PUBLIC SECTION.
7 CLASS-METHODS append_error
8 CHANGING ct_message TYPE usmd_t_message
9 IMPORTING iv_msgid TYPE symsgid
10 iv_msgno TYPE symsgno
11 iv_fieldname TYPE usmd_fieldname OPTIONAL
12 iv_msgv1 TYPE symsgv OPTIONAL
13 iv_msgv2 TYPE symsgv OPTIONAL.
14
15 CLASS-METHODS append_table
16 CHANGING ct_target TYPE usmd_t_message
17 ct_source TYPE usmd_t_message.
18
19 CLASS-METHODS enrich_navigation
20 IMPORTING io_model TYPE REF TO if_usmd_model_ext
21 iv_crequest TYPE usmd_crequest
22 iv_entitytype TYPE usmd_entity
23 CHANGING ct_message TYPE usmd_t_message.
24
25 CLASS-METHODS normalize_message_severity
26 IMPORTING iv_crequest TYPE usmd_crequest
27 CHANGING ct_message TYPE usmd_t_message.
28ENDCLASS.
29
30CLASS zcl_usmd_check_entity_skill IMPLEMENTATION.
31
32 METHOD append_error.
33 DATA ls_message TYPE usmd_s_message.
34 ls_message-msgid = iv_msgid.
35 ls_message-msgno = iv_msgno.
36 ls_message-msgty = 'E'.
37 ls_message-fieldname = iv_fieldname.
38 ls_message-msgv1 = iv_msgv1.
39 ls_message-msgv2 = iv_msgv2.
40 APPEND ls_message TO ct_message.
41 ENDMETHOD.
42
43 METHOD append_table.
44 IF ct_source IS NOT INITIAL.
45 APPEND LINES OF ct_source TO ct_target.
46 CLEAR ct_source.
47 ENDIF.
48 ENDMETHOD.
49
50 METHOD enrich_navigation.
51 zcl_mdg_suppl_utility=>get_message_row_id(
52 EXPORTING
53 io_model = io_model
54 id_crequest = iv_crequest
55 id_entitytype = iv_entitytype
56 CHANGING
57 ct_message = ct_message ).
58 ENDMETHOD.
59
60 METHOD normalize_message_severity.
61 zcl_mdgbp_bp_validation=>adjust_messages(
62 EXPORTING
63 cr_number = iv_crequest
64 CHANGING
65 ct_message = ct_message ).
66 ENDMETHOD.
67
68ENDCLASS.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How should I build validation messages in IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY?
- What is the recommended pattern for ET_MESSAGE in SAP MDG entity validation?
- How do I add field-level error messages and navigation for MDG CHECK_ENTITY?
Possible questions
- How do I populate ET_MESSAGE correctly in SAP MDG CHECK_ENTITY validation logic?
- How should I build validation messages in IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY?
- What is the recommended pattern for ET_MESSAGE in SAP MDG entity validation?
- How do I add field-level error messages and navigation for MDG CHECK_ENTITY?
- How do I normalize and enrich MDG validation messages before returning them?