SAP MDG · VALIDATION DERIVATION
How do I implement cross-entity derivation in SAP MDG using USMD_RULE_SERVICE_CROSS_ET?
Implement the logic in IF_EX_USMD_RULE_SERVICE2~DERIVE and keep it as an orchestration method: guard unbound framework references, read the MDG application context, route by change request type/process, read deltas first, then derive to the write buffer through io_write_data. In the referenced implementation, the main class is ZCL_MDGBP_BP_CROSS_DERIVATION, with helper methods for customer defaults/roles/license and supplier defaults/roles/email/message/business-details.
Implement the logic in IF_EX_USMD_RULE_SERVICE2~DERIVE and keep it as an orchestration method: guard unbound framework references, read the MDG application context, route by change request type/process, read deltas first, then derive to the write buffer through io_write_data. In the referenced implementation, the main class is ZCL_MDGBP_BP_CROSS_DERIVATION, with helper methods for customer defaults/roles/license and supplier defaults/roles/email/message/business-details.
In SAP MDG, cross-entity derivation for BAdI USMD_RULE_SERVICE_CROSS_ET is implemented in the interface method IF_EX_USMD_RULE_SERVICE2~DERIVE. The documented pattern is to keep DERIVE small, use CL_USMD_APP_CONTEXT to identify the change request and process, read existing deltas from IF_USMD_DELTA_BUFFER_READ, then update only the MDG write buffer via IF_USMD_DELTA_BUFFER_WRITE. The referenced system implementation uses ZCL_MDGBP_BP_CROSS_DERIVATION as the main router class, with helper methods for customer and supplier branches.
Process flow
- Open SE18 and verify the BAdI definition
USMD_RULE_SERVICE_CROSS_ETand interface IF_EX_USMD_RULE_SERVICE2. - Create or maintain the implementation in SE19 and assign the implementing class.
- Implement IF_EX_USMD_RULE_SERVICE2~DERIVE as the orchestration entry point.
- Read the application context with CL_USMD_APP_CONTEXT=>GET_CONTEXT( ).
- Route by change request type, process, and step.
- Read delta data before deriving and write only through IO_WRITE_DATA.
- Catch CX_USMD_WRITE_ERROR and append ET_MESSAGE_INFO entries.
- Test all impacted change request types and derivation branches.
Referenced tables
| Object | Purpose |
|---|---|
USMD_T_MESSAGE | Message table returned through ET_MESSAGE_INFO for derivation messages. |
ZMDG_TT_BP_ES_BP_ROLE | Role data table used by GET_ROLES_DATA. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1class ZCL_MDGBP_BP_CROSS_DERIVATION definition
2 public
3 final
4 create public .
5
6public section.
7
8 interfaces IF_BADI_INTERFACE .
9 interfaces IF_EX_USMD_RULE_SERVICE2 .
10
11 class-data GV_ZZKTOKD type KTOKD .
12 class-data GV_GLB_BUGRP type BU_GROUP .
13 class-data GV_BUGRP_DERIV type BOOLEAN .
14
15 methods DERIVE_CUST_DEFAULTS
16 importing
17 !IO_MODEL type ref to IF_USMD_MODEL_EXT
18 !IO_CHANGED_DATA type ref to IF_USMD_DELTA_BUFFER_READ
19 !IO_WRITE_DATA type ref to IF_USMD_DELTA_BUFFER_WRITE
20 exporting
21 !ET_MESSAGE_INFO type USMD_T_MESSAGE .
22 methods DERIVE_CUST_ROLES
23 importing
24 !IO_MODEL type ref to IF_USMD_MODEL_EXT
25 !IO_CHANGED_DATA type ref to IF_USMD_DELTA_BUFFER_READ
26 !IO_WRITE_DATA type ref to IF_USMD_DELTA_BUFFER_WRITE
27 exporting
28 !ET_MESSAGE_INFO type USMD_T_MESSAGE .
29 methods GET_ROLES_DATA
30 importing
31 !IO_MODEL type ref to IF_USMD_MODEL_EXT optional
32 !IO_CHANGED_DATA type ref to IF_USMD_DELTA_BUFFER_READ optional
33 !IT_DATA_ENTITY type USMD_TS_DATA_ENTITY optional
34 !IV_BP_CENTRL type /MDGBP/_S_BP_PP_BP_CENTRL optional
35 exporting
36 !ET_ROLES type ZMDG_TT_BP_ES_BP_ROLE .
37 methods DERIVE_SUP_DEFAULTS
38 importing
39 !IO_MODEL type ref to IF_USMD_MODEL_EXT
40 !IO_CHANGED_DATA type ref to IF_USMD_DELTA_BUFFER_READ
41 !IO_WRITE_DATA type ref to IF_USMD_DELTA_BUFFER_WRITE
42 !IV_CREQUEST_TYPE type USMD_CREQUEST_TYPE
43 !IV_CREQUEST_ID type USMD_CREQUEST
44 !IV_CREQUEST_STEP type USMD_CREQUEST_APPSTEP
45 !IV_BU_GROUP type BU_GROUP optional
46 !ID_ACC_GRP type KTOKK optional
47 exporting
48 !ET_MESSAGE_INFO type USMD_T_MESSAGE
49 !EV_KTOKK type KTOKK .
50 methods DERIVE_SUPPL_ROLES
51 importing
52 !IO_MODEL type ref to IF_USMD_MODEL_EXT
53 !IO_CHANGED_DATA type ref to IF_USMD_DELTA_BUFFER_READ
54 !IO_WRITE_DATA type ref to IF_USMD_DELTA_BUFFER_WRITE
55 !IV_CREQUEST_TYPE type USMD_CREQUEST_TYPE
56 !IV_CREQUEST_ID type USMD_CREQUEST
57 !IV_BU_GROUP type BU_GROUP optional
58 exporting
59 !ET_MESSAGE_INFO type USMD_T_MESSAGE .
60 methods DERIVE_SUPPL_AD_EMAIL
61 importing
62 !IO_MODEL type ref to IF_USMD_MODEL_EXT
63 !IO_CHANGED_DATA type ref to IF_USMD_DELTA_BUFFER_READ
64 !IO_WRITE_DATA type ref to IF_USMD_DELTA_BUFFER_WRITE
65 !IV_CREQUEST_TYPE type USMD_CREQUEST_TYPE
66 !IV_CREQUEST_ID type USMD_CREQUEST
67 !IV_BU_GROUP type BU_GROUP optional
68 exporting
69 !ET_MESSAGE_INFO type USMD_T_MESSAGE .
70 methods DERIVE_SUPPL_ZBP_MSG
71 importing
72 !IO_MODEL type ref to IF_USMD_MODEL_EXT
73 !IO_CHANGED_DATA type ref to IF_USMD_DELTA_BUFFER_READ
74 !IO_WRITE_DATA type ref to IF_USMD_DELTA_BUFFER_WRITE
75 !IV_CREQUEST_TYPE type USMD_CREQUEST_TYPE
76 !IV_CREQUEST_ID type USMD_CREQUEST
77 !IV_BU_GROUP type BU_GROUP optional
78 exporting
79 !ET_MESSAGE_INFO type USMD_T_MESSAGE .
80 methods DERIVE_SUPPL_BUDET
81 importing
82 !IO_MODEL type ref to IF_USMD_MODEL_EXT
83 !IO_CHANGED_DATA type ref to IF_USMD_DELTA_BUFFER_READ
84 !IO_WRITE_DATA type ref to IF_USMD_DELTA_BUFFER_WRITE
85 !IV_CREQUEST_TYPE type USMD_CREQUEST_TYPE
86 !IV_CREQUEST_ID type USMD_CREQUEST
87 !IV_BU_GROUP type BU_GROUP optional
88 exporting
89 !ET_MESSAGE_INFO type USMD_T_MESSAGE .
90protected section.
91private section.
92
93 methods DERIVE_CUST_LICENSE
94 importing
95 !IO_MODEL type ref to IF_USMD_MODEL_EXT
96 !IO_CHANGED_DATA type ref to IF_USMD_DELTA_BUFFER_READ
97 !IO_WRITE_DATA type ref to IF_USMD_DELTA_BUFFER_WRITE
98 !IT_DATA_ENTITY type USMD_TS_DATA_ENTITY
99 exporting
100 !ET_MESSAGE_INFO type USMD_T_MESSAGE .
101ENDCLASS.
102
103
104
105CLASS ZCL_MDGBP_BP_CROSS_DERIVATION IMPLEMENTATION.
106
107
108 METHOD derive_cust_defaults.
109 CONSTANTS:
110 lc_headr TYPE usmd_entity VALUE 'BP_HEADER',
111 lc_indstr TYPE usmd_entity VALUE 'BP_INDSTR',
112 lc_cusgen TYPE usmd_entity VALUE 'BP_CUSGEN',
113 lc_centrl TYPE usmd_entity VALUE 'BP_CENTRL',
114 lc_custax TYPE usmd_entity VALUE 'BP_CUSTAX',
115 lc_postal TYPE usmd_entity VALUE 'AD_POSTAL',
116 lc_fs_bp001 TYPE usmd_entity VALUE 'FS_BP001',
117 lc_address TYPE usmd_entity VALUE 'ADDRESS'.
118
119 DATA:
120 ls_bpheader TYPE /mdgbp/_s_bp_es_bp_header,The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How do I derive values from BP to customer/supplier entities in MDG?
- What is the ABAP pattern for IF_EX_USMD_RULE_SERVICE2~DERIVE?
- How do I update MDG entities from the derivation BAdI without direct table updates?
Possible questions
- How do I implement supplier default derivation in MDG?
- How do I derive BP grouping from customer account group in MDG?
- How do I append blank rows for a custom MDG message entity?
- How do I read changed entity data from the MDG delta buffer?
- How do I avoid duplicate row generation in MDG derivation?