SAP MDG · VALIDATION DERIVATION
How do I implement SAP MDG entity-level validation in BAdI USMD_RULE_SERVICE method CHECK_ENTITY?
Implement the validation in BAdI USMD_RULE_SERVICE, method IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY, by gating on ID_ENTITYTYPE, looping over IT_DATA, checking the needed fields generically with ASSIGN COMPONENT, and appending business errors to ET_MESSAGE as USMD_S_MESSAGE entries.
Implement the validation in BAdI USMD_RULE_SERVICE, method IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY, by gating on ID_ENTITYTYPE, looping over IT_DATA, checking the needed fields generically with ASSIGN COMPONENT, and appending business errors to ET_MESSAGE as USMD_S_MESSAGE entries.
In SAP MDG, CHECK_ENTITY is the standard place to validate the attributes of a single entity type’s records inside a change request. The implementation pattern is: clear ET_MESSAGE, optionally read change-request context from CL_USMD_APP_CONTEXT, loop over IT_DATA, read fields with ASSIGN COMPONENT, and append business errors as USMD_S_MESSAGE rows.
Process flow
- Open SE18 and display BAdI
USMD_RULE_SERVICEto confirm interface IF_EX_USMD_RULE_SERVICE and method purpose. - Create or open the BAdI implementation in SE19.
- Assign the implementing class and implement IF_EX_USMD_RULE_SERVICE.
- In CHECK_ENTITY, clear ET_MESSAGE at the start and gate by ID_ENTITYTYPE.
- Optionally read CR context using CL_USMD_APP_CONTEXT=>GET_CONTEXT( ).
- Loop over IT_DATA and read required fields with ASSIGN COMPONENT.
- Build
USMD_S_MESSAGEentries with MSGTY, MSGID, MSGNO, and message variables. - Append each validation failure to ET_MESSAGE and activate the class and BAdI implementation.
SE18Display BAdI definition USMD_RULE_SERVICE
Check interface IF_EX_USMD_RULE_SERVICE, method intent, and whether filters are required.
SE19Create BAdI Implementation for USMD_RULE_SERVICE
Create the implementation, assign the class, and maintain the MDG data-model filter such as MM, BP, or 0G.
Referenced tables
| Object | Purpose |
|---|---|
USMD_S_MESSAGE | Message structure used to return validation messages from CHECK_ENTITY. |
USMD_TS_MESSAGE | Table type of validation messages returned in ET_MESSAGE. |
USMD1_CS_MSGTY | Severity constants for MDG messages, such as error, warning, and info. |
The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How do I write a CHECK_ENTITY validation for SAP MDG?
- How do I validate records of a single MDG entity in
USMD_RULE_SERVICE? - What is the implementation pattern for IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY?
Possible questions
- How do I implement SAP MDG entity-level validation in BAdI
USMD_RULE_SERVICEmethod CHECK_ENTITY? - How do I write a CHECK_ENTITY validation for SAP MDG?
- How do I validate records of a single MDG entity in
USMD_RULE_SERVICE? - What is the implementation pattern for IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY?
- Which transaction code is used to register
USMD_RULE_SERVICE? - How do I build the validation message in ET_MESSAGE?
- How do I gate CHECK_ENTITY by entity type and change-request step?