SAP MDG · VALIDATION DERIVATION
How do I implement a real SAP MDG CHECK_ENTITY validation in BAdI USMD_RULE_SERVICE?
Use BAdI USMD_RULE_SERVICE in SE18/SE19, assign an implementing class for IF_EX_USMD_RULE_SERVICE, and replace the empty CHECK_ENTITY stub with entity-gated validation logic that loops over IT_DATA, checks required fields, and appends messages to ET_MESSAGE with MSGID, MSGNO, MSGTY, and FIELDNAME.
Use BAdI USMD_RULE_SERVICE in SE18/SE19, assign an implementing class for IF_EX_USMD_RULE_SERVICE, and replace the empty CHECK_ENTITY stub with entity-gated validation logic that loops over IT_DATA, checks required fields, and appends messages to ET_MESSAGE with MSGID, MSGNO, MSGTY, and FIELDNAME.
Use BAdI USMD_RULE_SERVICE for entity-level MDG validation. The empty CHECK_ENTITY method is only a placeholder; the real implementation should read the application context, gate the logic by model/entity type, loop over IT_DATA, and return business errors in ET_MESSAGE so the CR UI can display them.
Process flow
- Open SE18 and display BAdI definition
USMD_RULE_SERVICE. - Confirm the interface IF_EX_USMD_RULE_SERVICE and whether the BAdI is filter-dependent.
- Open SE19 and create the implementation with Z* naming, description, package, and transport request.
- Maintain filter values if the BAdI is filter-dependent.
- Assign or create the implementing class and implement IF_EX_USMD_RULE_SERVICE.
- Code CHECK_ENTITY with entity gating, field checks, and ET_MESSAGE population.
- Activate the class, then the BAdI implementation, then dependent objects.
- Test in the relevant MDG business scenario with breakpoints and message verification.
Referenced tables
| Object | Purpose |
|---|---|
USMD_S_MESSAGE | Message structure used to return validation messages in ET_MESSAGE. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP implementation example
Concrete CHECK_ENTITY implementation pattern from the same knowledge document set.
1METHOD if_ex_usmd_rule_service~check_entity.
2 DATA: lo_app_context TYPE REF TO if_usmd_app_context,
3 lt_message TYPE usmd_t_message,
4 ls_message TYPE usmd_s_message,
5 lv_crtype TYPE usmd_crequest_type,
6 lv_crstep TYPE usmd_crequest_appstep,
7 lv_crid TYPE usmd_crequest.
8
9 FIELD-SYMBOLS: <ls_data> TYPE any,
10 <lv_value> TYPE any.
11
12 lo_app_context = cl_usmd_app_context=>get_context( ).
13 CHECK lo_app_context IS BOUND.
14 CHECK io_model->d_usmd_model = 'BP'.
15
16 lo_app_context->get_attributes(
17 IMPORTING
18 ev_crequest_type = lv_crtype
19 ev_crequest_step = lv_crstep
20 ev_crequest_id = lv_crid ).
21
22 CHECK it_data IS NOT INITIAL.
23
24 LOOP AT it_data ASSIGNING <ls_data>.
25 ASSIGN COMPONENT 'SOME_MAND_FIELD' OF STRUCTURE <ls_data> TO <lv_value>.
26 IF <lv_value> IS ASSIGNED AND <lv_value> IS INITIAL.
27 CLEAR ls_message.
28 ls_message-msgid = 'ZMDG_SUPPL'.
29 ls_message-msgno = '001'.
30 ls_message-msgty = 'E'.
31 ls_message-fieldname = 'SOME_MAND_FIELD'.
32 APPEND ls_message TO et_message.
33 ENDIF.
34 ENDLOOP.
35
36 IF et_message IS NOT INITIAL.
37 zcl_mdgbp_bp_validation=>adjust_messages(
38 EXPORTING
39 cr_number = lv_crid
40 CHANGING
41 ct_message = et_message ).
42 ENDIF.
43ENDMETHOD.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How do I replace an empty CHECK_ENTITY stub with validation logic in SAP MDG?
- What is the implementation pattern for IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY in MDG?
- How do I create a validation BAdI implementation for
USMD_RULE_SERVICEin SE18/SE19?
Possible questions
- How do I implement a real SAP MDG CHECK_ENTITY validation in BAdI
USMD_RULE_SERVICE? - How do I replace an empty CHECK_ENTITY stub with validation logic in SAP MDG?
- What is the implementation pattern for IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY in MDG?
- How do I create a validation BAdI implementation for
USMD_RULE_SERVICEin SE18/SE19? - Which message fields should I fill in ET_MESSAGE for MDG validations?