SAP MDG · VALIDATION DERIVATION
How do I implement SAP MDG BP validation in IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY for business partner and supplier rules?
Implement the USMD_RULE_SERVICE BAdI so that CHECK_ENTITY reads the MDG application context first, gates the logic by model/process/CR type, validates the current entity data with dynamic field access, appends messages to ET_MESSAGE, and then applies message adjustment and navigation enrichment.
Implement the USMD_RULE_SERVICE BAdI so that CHECK_ENTITY reads the MDG application context first, gates the logic by model/process/CR type, validates the current entity data with dynamic field access, appends messages to ET_MESSAGE, and then applies message adjustment and navigation enrichment.
IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY is the standard MDG entry point for entity-level validation. In the BP validation pattern, the method first reads the application context, checks that the model is BP, derives CR type, step, process, and grouping/account context, then runs entity-specific checks and appends all findings to ET_MESSAGE. It also supports message-field navigation and central severity adjustment.
Process flow
- Open SE18 and display BAdI definition
USMD_RULE_SERVICE. - Create or open the implementation in SE19 and assign a Z* class.
- Implement IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY in the class.
- Read CL_USMD_APP_CONTEXT first and guard by model BP.
- Read CR type, CR step, CR number, and process once.
- Validate IT_DATA with dynamic ASSIGN COMPONENT checks and/or helper calls.
- Append validation findings to ET_MESSAGE using usmd_s_message.
- If required, enrich FIELDNAME/row mapping for navigation using the TVARVC switch ZMDG_VMD_MSG_NAVIGATION_ACTIVE to control it throughout the solution pattern described in the source sample (maintained in TVARVC). In the sample code, the TVR
Name = ZMDG_GTS_ALLOWED_CR
Controls which CR types are allowed for the GTS-related step logic in the sample pattern.
Name = ZMDG_VMD_MSG_NAVIGATION_ACTIVE
Activates message navigation enrichment and row-ID mapping in the sample pattern.
Referenced tables
| Object | Purpose |
|---|---|
TVARVC | Holds runtime switches used by the BP validation pattern, including CR-type gating and message navigation activation. |
USMD120C | Used in the sample to check whether a change request has change documents/entries before additional changed-field processing. |
BUT000 | Used in the sample to derive the BP creation date for go-live based validation logic. |
ZMDG_GOLIVECONF | Custom go-live configuration table used to determine the validation start date by system ID. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1METHOD if_ex_usmd_rule_service~check_entity.
2*&H ------------------------------------------------------------------*
3*&H HEADER INFORMATION
4*&H-------------------------------------------------------------------*
5*&H AUTHOR: | Favela Rafael
6*&H Team : | SAP MDG
7*&H Date: | 14.02.2024
8*$*$------------------------------------------------------------------*
9*&D MDG BP Validation
10*$*$------------------------------------------------------------------*
11*&A Start CHANGE HISTORY
12*$*$------------------------------------------------------------------*
13*&A Program changes:
14*$*$------------------------------------------------------------------*
15*&A Date |TA-No. | Programmer (Initials)
16*$*$------------------------------------------------------------------*
17*&A | |
18*$*$------------------------------------------------------------------*
19**Data Declaration
20* check sy-uname ne 'TE476016'.
21 DATA:
22 lo_app_context TYPE REF TO if_usmd_app_context,
23 ls_bp_sales TYPE /mdgbpx/_s_bp_pp_bp_sales,
24 lv_crstep TYPE usmd_crequest_appstep,
25 lv_crtype TYPE usmd_crequest_type,
26 lv_cr_number TYPE usmd_crequest,
27 lv_bu_group TYPE bu_group,
28 lt_message TYPE usmd_t_message,
29 lt_mand_message TYPE usmd_t_message,
30 lv_bp_sales_vtweg TYPE vtweg,
31 lv_bp_sales_vkorg TYPE vkorg,
32 lv_bp_sales_kvgr1 TYPE kvgr1,
33 buffer TYPE xstring,
34 lv_acc_grp TYPE ktokk,
35 lv_vkorg_land1 TYPE land1,
36 ls_message TYPE usmd_s_message.
37
38
39 FIELD-SYMBOLS:
40 <fs_ls_data> TYPE any.
41 "Get Application Context
42
43 lo_app_context = cl_usmd_app_context=>get_context( ).
44
45 CHECK lo_app_context IS BOUND.
46
47 "Check Data Model
48 CHECK io_model->d_usmd_model = 'BP'.
49
50
51 "Get Context Values
52 lo_app_context->get_attributes(
53 IMPORTING
54 ev_crequest_step = lv_crstep
55 ev_crequest_type = lv_crtype
56 ev_crequest_id = lv_cr_number
57 ev_process = DATA(lv_process) ).
58
59
60
61
62 IF lv_cr_number IS NOT INITIAL AND ( lv_crtype = zif_bp_constants=>creq_type-zsupl2p1 OR
63 lv_crtype = zif_bp_constants=>creq_type-zsupl4p2 ).
64 EXPORT lv_cr_number = lv_cr_number TO DATA BUFFER buffer.
65 MODIFY demo_expressions FROM @(
66 VALUE #( id = 'B' xstring1 = buffer char1 = lv_crtype ) ). "#EC CI_SUBRC
67 ENDIF.
68****soc by TE581834 GTS call at requester and final approver step
69 DATA: io_event TYPE REF TO if_fpm,
70 lv_action TYPE usmd_crequest_action.
71 cl_fpm=>get_instance(
72 RECEIVING
73 ro_instance = io_event " Interface for accessing FPM functionality
74 ).
75 IF io_event IS BOUND AND ( id_entitytype = 'BP_CUSGEN' OR id_entitytype = 'BP_VENGEN' ).
76 io_event->read_event_queue(
77 IMPORTING
78 et_event_queue = DATA(lt_event_queue)
79 ).
80 DATA(ls_event_queue) = lt_event_queue[ 1 ].
81 DATA(lv_lines) = lines( ls_event_queue-parameter ).
82 SELECT * FROM tvarvc INTO TABLE @DATA(lt_crtype) WHERE name = 'ZMDG_GTS_ALLOWED_CR'.
83 IF sy-subrc = 0 AND line_exists( lt_crtype[ low = lv_crtype ] ) AND lv_crstep NE '00'.
84 IF ( ls_event_queue-id = 'Z1' OR ls_event_queue-id = 'Z2' OR ls_event_queue-id = 'Z3' OR ls_event_queue-id = 'Z4'
85 OR ls_event_queue-id = 'Z5' OR ls_event_queue-id = 'Z6' OR ls_event_queue-id = '03' OR ls_event_queue-id = '05'
86 OR ls_event_queue-id = '09' OR ls_event_queue-id = '07' )"OR ls_event_queue-id = 'CR_SUBMIT' )
87* OR ( ls_event_queue-id = 'CR_CHECK' AND lv_lines = 4 )
88 OR ( ls_event_queue-id = 'CR_CHECK' AND lv_process = 'SUP1' AND lv_crtype EQ 'ZSUPL1P1' AND lv_crstep NE '12' AND lv_crstep NE '00' )
89 OR ( ls_event_queue-id = 'CR_CHECK' AND lv_process = 'SUP1' AND lv_crtype NE 'ZSUPL1P1' AND lv_crstep NE '00' )
90 OR ( ls_event_queue-id = 'CR_CHECK' AND lv_process = 'CUP1' AND lv_crstep NE '00' )
91 OR ( ls_event_queue-id = 'CR_CHECK' AND lv_process EQ 'CUP2' )
92 OR ( ls_event_queue-id = 'CR_CHECK' AND lv_process EQ 'SUP2' AND lv_crstep = '00' )
93 OR ( lv_process EQ 'SUP6' OR lv_process EQ 'CUP6' ).
94* SELECT * FROM tvarvc INTO TABLE @DATA(lt_scenario) WHERE name = 'ZMDG_ONBOARDING_CR'.
95* IF ( lt_scenario IS NOT INITIAL AND line_exists( lt_scenario[ low = lv_crtype ] ) AND lo_app_context->mv_crequest_step = '12' AND ls_event_queue-id = '03' ) OR
96* ( ls_event_queue-id = '07' OR ls_event_queue-id = 'CR_SUBMIT' ).
97 IF lv_crstep NE '00'.
98 lv_action = '03'.
99 ENDIF.
100 zcl_mdg_bp_util=>check_next_approver(
101 EXPORTING
102 iv_req_first_call = gv_gts_first_call
103 IMPORTING
104 et_message = lt_message " Messages
105 ev_final = DATA(lv_final)
106 CHANGING
107 cv_action = lv_action " Action in Change Request Step
108 ).
109 IF lv_action <> '06'.
110 gv_gts_first_call = abap_false.
111 ENDIF.
112 LOOP AT lt_message INTO ls_message.
113 IF lv_crstep NE '00'."ls_event_queue-id NE '07' AND ls_event_queue-id = 'CR_SUBMIT'.
114 IF lv_crtype EQ 'ZSUPL1P1' AND lv_crstep NE '12'.
115 ls_message-msgty = 'W'.
116 ELSEIF lv_crtype NE 'ZSUPL1P1'.
117 ls_message-msgty = 'W'.
118 ENDIF.
119 ENDIF.
120 APPEND ls_message TO et_message.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How do I build a custom MDG BP validation BAdI for CHECK_ENTITY?
- What is the recommended pattern for validating MDG Business Partner data in CHECK_ENTITY?
- How can I add supplier and BP entity checks in
USMD_RULE_SERVICE?
Possible questions
- How do I implement SAP MDG BP validation in IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY for business partner and supplier rules?
- How do I create a BAdI implementation for
USMD_RULE_SERVICE? - What is the purpose of CHECK_ENTITY in MDG?
- How do I add message navigation and severity control in MDG validation?
- How do I route MDG validation by CR type, process, and workflow step?