SAP MDG · VALIDATION DERIVATION
How do I implement MDG BP cross-entity derivation in BAdI USMD_RULE_SERVICE_CROSS_ET?
Implement the BAdI logic in IF_EX_USMD_RULE_SERVICE2~DERIVE and keep it as a router: read the MDG context, branch by change request type/process/step, derive customer and supplier dependent values in deterministic order, and write only through IO_WRITE_DATA with structured messages.
Implement the BAdI logic in IF_EX_USMD_RULE_SERVICE2~DERIVE and keep it as a router: read the MDG context, branch by change request type/process/step, derive customer and supplier dependent values in deterministic order, and write only through IO_WRITE_DATA with structured messages.
ZCL_MDGBP_BP_CROSS_DERIVATION is the documented MDG BP cross-derivation class for USMD_RULE_SERVICE_CROSS_ET. It uses IF_EX_USMD_RULE_SERVICE2~DERIVE as the framework entry point, reads the MDG context and delta buffers, then routes to focused submethods for customer defaults, customer roles, supplier defaults, supplier roles, supplier email/business-details logic, and customer license derivation.
Process flow
- Open transaction
SE18and display the BAdI definitionUSMD_RULE_SERVICE_CROSS_ETor the relevant rule-service definition. - Create or open the SE19 implementation and assign the implementing class.
- Implement IF_EX_USMD_RULE_SERVICE2~DERIVE as the orchestration entry point.
- Read application context, CR type, process, and step before branching.
- Read existing delta data from IO_CHANGED_DATA before deriving.
- Call focused helper methods for customer and supplier branches.
- Write updates only through IO_WRITE_DATA and catch CX_USMD_WRITE_ERROR.
- Append structured messages in ET_MESSAGE_INFO and test all impacted change request types.
Referenced tables
| Object | Purpose |
|---|---|
USMD_T_MESSAGE | Message table used for structured derivation messages returned in ET_MESSAGE_INFO. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example: CL_MDG_BS_MAT_CLF2DESCRIPTION.abap
Exact relevant implementation excerpt from the knowledge document set.
1class CL_MDG_BS_MAT_CLF2DESCRIPTION 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-methods CLASS_CONSTRUCTOR .
12protected section.
13private section.
14
15 types:
16 ty_valuation_tab TYPE STANDARD TABLE OF /mdgmm/_s_mm_pp_valuation WITH DEFAULT KEY .
17
18 constants GC_CLASSTYPE type KLASSENART value '001'. "#EC NOTEXT
19 constants GC_CHARNAME1 type ATNAM value 'IB_TYPE'. "#EC NOTEXT
20 constants GC_CHARNAME2 type ATNAM value 'IB_COLOR'. "#EC NOTEXT
21 class-data GV_CHARID1 type MDG_BS_CLF_CHARID .
22 class-data GV_CHARID2 type MDG_BS_CLF_CHARID .
23
24 class-methods READ_CLASSIFICATION
25 importing
26 !IV_MATNR type MATNR
27 !IV_CLASSTYPE type KLASSENART
28 !IO_MODEL type ref to IF_USMD_MODEL_EXT
29 returning
30 value(RT_VALUATION) type TY_VALUATION_TAB
31 raising
32 CX_MDG_BS_MAT_GEN .
33 class-methods GET_ATINN
34 importing
35 !IV_CHARNAME type ATNAM
36 returning
37 value(RV_CHARID) type ATINN .
38ENDCLASS.
39
40
41
42CLASS CL_MDG_BS_MAT_CLF2DESCRIPTION IMPLEMENTATION.
43
44
45method CLASS_CONSTRUCTOR.
46 " Get the internal characteristic IDs
47 gv_charid1 = get_atinn( gc_charname1 ).
48 gv_charid2 = get_atinn( gc_charname2 ).
49endmethod.
50
51
52METHOD get_atinn.
53 DATA: lt_cabn TYPE STANDARD TABLE OF cabn.
54 DATA: ls_cabn TYPE cabn.
55 CLEAR rv_charid.
56 ASSERT iv_charname <> space.
57 " Read internal characteristic ID from characteristic name
58 CALL FUNCTION 'CLSE_SELECT_CABN_VIA_NAME'
59 EXPORTING
60 characteristic = iv_charname
61 TABLES
62 t_cabn = lt_cabn
63 EXCEPTIONS
64 OTHERS = 0.
65 READ TABLE lt_cabn INTO ls_cabn INDEX 1.
66 rv_charid = ls_cabn-atinn.
67ENDMETHOD.
68
69
70METHOD if_ex_usmd_rule_service2~derive.
71* Merges the valuation of two characteristics (hard-coded on IDs) into description
72* Assumptions:
73* - No change number
74* - No multi-value characteristics
75 DATA: lt_valuation TYPE ty_valuation_tab.
76 DATA: ls_valuation TYPE /mdgmm/_s_mm_pp_valuation.
77 DATA: lr_exc TYPE REF TO cx_mdg_bs_mat_gen.
78 DATA: ls_message TYPE usmd_s_message.
79 DATA: lr_mod TYPE REF TO data.
80 DATA: lt_attribute TYPE usmd_ts_fieldname.
81 DATA: lrt_entity_data TYPE REF TO data.
82 DATA: ls_description TYPE /mdgmm/_st_mm_pp_material.
83 DATA: lv_description TYPE usmd_txtmi.
84 DATA: lv_found1 TYPE abap_bool.
85 DATA: lv_found2 TYPE abap_bool.
86 DATA: lv_value1 TYPE atwrt.
87 DATA: lv_value2 TYPE atwrt.
88 DATA: lt_matnr TYPE SORTED TABLE OF matnr WITH UNIQUE KEY table_line.
89 DATA: lr_descr_struc TYPE REF TO data.
90 DATA: lo_structdescr TYPE REF TO cl_abap_structdescr.
91 FIELD-SYMBOLS: <lf_component> TYPE abap_compdescr.
92 FIELD-SYMBOLS: <lt_description> TYPE STANDARD TABLE.
93 FIELD-SYMBOLS: <ls_description> TYPE any.
94 FIELD-SYMBOLS: <lt_mod> TYPE SORTED TABLE.
95 FIELD-SYMBOLS: <ls_mod> TYPE any.
96 FIELD-SYMBOLS: <lv_matnr> TYPE matnr.
97 CLEAR: et_message_info.
98 " Only consider changed valuations
99 CALL METHOD io_changed_data->read_data
100 EXPORTING
101 i_entity = if_mdg_bs_mat_gen_c=>gc_entity_valuation
102 IMPORTING
103 er_t_data_mod = lr_mod.
104 CHECK lr_mod IS BOUND.
105 ASSIGN lr_mod->* TO <lt_mod>.
106 CHECK sy-subrc = 0 AND <lt_mod> IS ASSIGNED AND <lt_mod> IS NOT INITIAL.
107 " Get the material numbers
108 LOOP AT <lt_mod> ASSIGNING <ls_mod>.
109 ASSIGN COMPONENT if_mdg_bs_mat_gen_c=>gc_attr_material OF STRUCTURE <ls_mod> TO <lv_matnr>.
110 INSERT <lv_matnr> INTO TABLE lt_matnr.
111 ENDLOOP.
112 " Derive description for all changed materials
113 LOOP AT lt_matnr ASSIGNING <lv_matnr>.
114 CLEAR: lv_value1, lv_value2, lv_found1, lv_found2.
115 " Get the changed classification values
116 " if the two characteristics have been changed for the current material
117 LOOP AT <lt_mod> ASSIGNING <ls_mod>.
118 MOVE-CORRESPONDING <ls_mod> TO ls_valuation.
119 CHECK ls_valuation-material = <lv_matnr>.
120 IF ls_valuation-charid = gv_charid1.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How do I use IF_EX_USMD_RULE_SERVICE2~DERIVE for BP customer and supplier derivation?
- What is the implementation pattern for ZCL_MDGBP_BP_CROSS_DERIVATION?
- How do I derive dependent BP values across customer and supplier entities in MDG?
Possible questions
- Which method is the technical implementation point for
USMD_RULE_SERVICE_CROSS_ET? - What does ZCL_MDGBP_BP_CROSS_DERIVATION derive?
- How should I structure DERIVE for MDG cross-entity logic?
- How do I avoid duplicate derived rows in MDG derivation?
- What are the main submethods used in BP cross derivation?