SAP MDG · VALIDATION DERIVATION
How do I implement an SAP MDG CHECK_ENTITY_HIERARCHY validation in USMD_RULE_SERVICE?
Use SE18 to inspect BAdI USMD_RULE_SERVICE, create the implementation in SE19, assign an ABAP class implementing IF_EX_USMD_RULE_SERVICE, and code hierarchy validation in CHECK_ENTITY_HIERARCHY only when your business rule depends on parent-child relationships. For simple record checks, use CHECK_ENTITY instead.
Use SE18 to inspect BAdI USMD_RULE_SERVICE, create the implementation in SE19, assign an ABAP class implementing IF_EX_USMD_RULE_SERVICE, and code hierarchy validation in CHECK_ENTITY_HIERARCHY only when your business rule depends on parent-child relationships. For simple record checks, use CHECK_ENTITY instead.
Use SE18 to review BAdI USMD_RULE_SERVICE and SE19 to create the implementation and assign the class. Then implement IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY_HIERARCHY only for hierarchy-based validation; the retrieved sample shows the method can remain empty when no hierarchy rule is required.
Process flow
- Open transaction
SE18and display BAdI definitionUSMD_RULE_SERVICE. - Check the interface name, use mode, filter dependency, and method intent.
- Open transaction
SE19and create the BAdI implementation. - Assign the implementation class and activate it.
- Implement `IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY_HIERARCHY` only for hierarchy-based checks.
- Keep the method empty if no hierarchy validation is required and use `CHECK_ENTITY` for flat validations.
- Activate the class and implementation.
- Debug by setting breakpoints and running the MDG scenario that calls the BAdI.
Referenced tables
| Object | Purpose |
|---|---|
usmd_s_message | Message structure used to return validation messages to the framework. |
usmd1_cs_msgty | Severity constants such as error, warning, and info. |
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 fill the CHECK_ENTITY_HIERARCHY method in an MDG BAdI implementation?
- What is the implementation approach for IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY_HIERARCHY?
- How do I turn the empty CHECK_ENTITY_HIERARCHY hook into working MDG logic?
Possible questions
- How do I implement an SAP MDG CHECK_ENTITY_HIERARCHY validation in
USMD_RULE_SERVICE? - What is the purpose of CHECK_ENTITY_HIERARCHY in IF_EX_USMD_RULE_SERVICE?
- How do I create and activate a BAdI implementation in SE18/SE19 for MDG rules?
- Can you show sample ABAP for an MDG validation method?
- When should I use CHECK_ENTITY versus CHECK_ENTITY_HIERARCHY?