SAP MDG · VALIDATION DERIVATION
How do I implement SAP MDG BP validation in `IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY` with process-specific rules and post-processing?
Use `IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY` as an orchestrator: read the MDG application context first, gate the logic by model `BP`, branch by process (`CUP1`/`CUP2` and `CUP5`), call reusable validation helpers, append returned messages to `ET_MESSAGE`, then enrich the messages and adjust severities.
Use `IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY` as an orchestrator: read the MDG application context first, gate the logic by model `BP`, branch by process (`CUP1`/`CUP2` and `CUP5`), call reusable validation helpers, append returned messages to `ET_MESSAGE`, then enrich the messages and adjust severities.
Use `IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY` as the main validation entry point for MDG BP checks. The source pattern reads the application context first, checks that the model is `BP`, then routes customer processes (`CUP1`/`CUP2`, `CUP5`) to dedicated validation helpers. Non-customer branches derive grouping from the change request and call reusable supplier validation rules before post-processing `ET_MESSAGE`.
Process flow
- Open SE18 and display the BAdI definition `
USMD_RULE_SERVICE`. - Open SE19 and create the BAdI implementation.
- Assign the implementing class and implement `IF_EX_USMD_RULE_SERVICE`.
- Implement `IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY` as a thin orchestrator.
- Read MDG application context with `CL_USMD_APP_CONTEXT=>GET_CONTEXT( )`.
- Check the model is `BP` before executing BP validation logic.
- Branch by process: `CUP1`/`CUP2`, `CUP5`, or supplier path.
- Call reusable validation helpers and append returned messages to `ET_MESSAGE`.
Referenced tables
| Object | Purpose |
|---|---|
USMD_T_MESSAGE | Message table type used to return validation issues from `CHECK_ENTITY`. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
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 lv_crstep TYPE usmd_crequest_appstep,
5 lv_crtype TYPE usmd_crequest_type,
6 lv_crid TYPE usmd_crequest,
7 lv_process TYPE usmd_process,
8 lv_bu_group TYPE bu_group,
9 lv_acc_grp TYPE ktokk.
10
11 lo_app_context = cl_usmd_app_context=>get_context( ).
12 CHECK lo_app_context IS BOUND.
13 CHECK io_model->d_usmd_model = 'BP'.
14
15 lo_app_context->get_attributes(
16 IMPORTING
17 ev_crequest_step = lv_crstep
18 ev_crequest_type = lv_crtype
19 ev_crequest_id = lv_crid
20 ev_process = lv_process ).
21
22 IF lv_process = 'CUP1' OR lv_process = 'CUP2'.
23 zcl_mdgbp_cust_validation=>validate_customer(
24 EXPORTING
25 io_model = io_model
26 iv_crequest_id = id_crequest
27 iv_crstep = lv_crstep
28 iv_crtype = lv_crtype
29 iv_process = lv_process
30 iv_entitytype = id_entitytype
31 it_entitydata = it_data
32 IMPORTING
33 et_message = et_message ).
34 RETURN.
35 ENDIF.
36
37 IF lv_process = 'CUP5'.
38 zcl_mdgbp_cust_validation=>validate_cup5(
39 EXPORTING
40 io_model = io_model
41 iv_crequest_id = id_crequest
42 iv_crstep = lv_crstep
43 iv_crtype = lv_crtype
44 iv_process = lv_process
45 iv_entitytype = id_entitytype
46 it_entitydata = it_data
47 IMPORTING
48 et_message = et_message ).
49 RETURN.
50 ENDIF.
51
52 zcl_mdg_suppl_utility=>get_single_attribute(
53 EXPORTING
54 im_crnumber = lv_crid
55 im_field = 'BU_GROUP'
56 IMPORTING
57 ex_value = DATA(lv_grouping) ).
58 lv_bu_group = lv_grouping.
59
60 " Delegated supplier validations
61 zcl_bp_validation_rule=>zif_te_validation~v_bp_centrl(
62 EXPORTING
63 io_model = io_model
64 id_edition = id_edition
65 id_entitytype = id_entitytype
66 id_crequest = id_crequest
67 it_data = it_data
68 id_crequest_type = lv_crtype
69 id_crequest_step = lv_crstep
70 IMPORTING
71 et_message = lt_message ).
72 APPEND LINES OF lt_message TO et_message.
73 CLEAR lt_message.
74
75 zcl_bp_validation_rule=>zif_te_validation~v_ad_postal(
76 EXPORTING
77 io_model = io_model
78 id_edition = id_edition
79 id_entitytype = id_entitytype
80 id_crequest = id_crequest
81 it_data = it_data
82 id_crequest_type = lv_crtype
83 id_crequest_step = lv_crstep
84 id_bu_group = lv_bu_group
85 IMPORTING
86 et_message = lt_message
87 ev_country = DATA(lv_country) ).
88 APPEND LINES OF lt_message TO et_message.
89 CLEAR lt_message.
90
91 zcl_bp_validation_rule=>zif_te_validation~v_com_code(
92 EXPORTING
93 io_model = io_model
94 id_edition = id_edition
95 id_entitytype = id_entitytype
96 id_crequest = id_crequest
97 it_data = it_data
98 id_crequest_type = lv_crtype
99 id_crequest_step = lv_crstep
100 id_bu_group = lv_bu_group
101 IMPORTING
102 et_message = lt_message ).
103 APPEND LINES OF lt_message TO et_message.
104 CLEAR lt_message.
105
106 " Navigation + severity normalization
107 zcl_mdg_suppl_utility=>get_message_row_id(
108 EXPORTING
109 io_model = io_model
110 id_crequest = id_crequest
111 id_entitytype = id_entitytype
112 CHANGING
113 ct_message = et_message ).
114
115 me->adjust_messages(
116 EXPORTING
117 cr_number = id_crequest
118 CHANGING
119 ct_message = et_message ).
120ENDMETHOD.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How do I build a BP validation BAdI in SAP MDG using `CHECK_ENTITY`?
- How do I route MDG BP validations by process in `IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY`?
- How do I implement customer and supplier validation logic in MDG BP `CHECK_ENTITY`?
Possible questions
- How do I implement SAP MDG BP validation in `IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY` with process-specific rules and post-processing?
- What is the standard pattern for `IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY` in BP validations?
- Which class and method are used for BP validation orchestration in MDG?
- How do I add process-based branching for customer and supplier checks in MDG?
- How do I normalize validation messages and add row navigation in MDG BP checks?