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

  1. Open SE18 and display BAdI USMD_RULE_SERVICE to confirm interface IF_EX_USMD_RULE_SERVICE and method purpose.
  2. Create or open the BAdI implementation in SE19.
  3. Assign the implementing class and implement IF_EX_USMD_RULE_SERVICE.
  4. In CHECK_ENTITY, clear ET_MESSAGE at the start and gate by ID_ENTITYTYPE.
  5. Optionally read CR context using CL_USMD_APP_CONTEXT=>GET_CONTEXT( ).
  6. Loop over IT_DATA and read required fields with ASSIGN COMPONENT.
  7. Build USMD_S_MESSAGE entries with MSGTY, MSGID, MSGNO, and message variables.
  8. Append each validation failure to ET_MESSAGE and activate the class and BAdI implementation.
SE18

Display BAdI definition USMD_RULE_SERVICE

Check interface IF_EX_USMD_RULE_SERVICE, method intent, and whether filters are required.

SE19

Create 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

ObjectPurpose
USMD_S_MESSAGEMessage structure used to return validation messages from CHECK_ENTITY.
USMD_TS_MESSAGETable type of validation messages returned in ET_MESSAGE.
USMD1_CS_MSGTYSeverity 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_SERVICE method 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?

Keywords

SAP MDGUSMD_RULE_SERVICEIF_EX_USMD_RULE_SERVICECHECK_ENTITYentity validationET_MESSAGECL_USMD_APP_CONTEXTSE18SE19usmd_s_messageusmd1_cs_msgty