SAP MDG · CONSOLIDATION
How do I implement custom supplier Change Request staging in SAP MDG consolidation with IF_MDG_BS_CUST_SUPP_CR_SI?
Implement BAdI definition MDG_BS_CUST_SUPP_CR_SI in SE19, create a helper object in CONSTRUCTOR, call the standard supplier staging logic first, then copy BP vendor API data into your custom staging structure and write it to the Governance API with write_entity.
Implement BAdI definition MDG_BS_CUST_SUPP_CR_SI in SE19, create a helper object in CONSTRUCTOR, call the standard supplier staging logic first, then copy BP vendor API data into your custom staging structure and write it to the Governance API with write_entity.
The source example shows a custom implementation of IF_MDG_BS_CUST_SUPP_CR_SI for consolidation upload staging. The pattern is: create the BAdI implementation in SE19, instantiate the standard supplier helper in CONSTRUCTOR, delegate the standard mapping first, then enrich the staging data for your custom entity and write it through the Governance API.
Process flow
- Start transaction
SE19. - Create a new BAdI implementation for BAdI Definition MDG_BS_CUST_SUPP_CR_SI.
- Use Enhancement Spot MDG_BS_CUST_SUPP_CR_SI.
- Select New BAdI and choose Create Impl.
- Create the implementation class, for example ZCL_BI_SUPP_CR_SI_ERP.
- In CONSTRUCTOR, create the standard supplier helper object.
- Redefine IF_MDG_BS_CUST_SUPP_CR_SI~MAP_BP_TO_STAGING_WO_CR and delegate to MO_SUPPLIER.
- Redefine IF_MDG_BS_CUST_SUPP_CR_SI~SET_SUPPLIER_DATA_2_STA to call standard logic first, then add custom data processing and Governance API writing.
Referenced tables
| Object | Purpose |
|---|---|
ZMDGBP_S_BP_PP_ZBP_SUPPL | Custom staging structure populated from supplier BP API data in the example. |
ZBP_SUPPL | Custom entity written to the Governance API in the example. |
USMD_ENTITY | Entity name list used to drive entity-specific write logic. |
MDG_BS_BP_S_EXTERN | Business partner API source structure used as input. |
ZVMDSE_EI_VMD_EXT_DATA | Vendor central data extension structure used as the dynamic source for field mapping. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1class ZCL_BI_SUPP_CR_SI_ERP definition
2 public
3 final
4 create public .
5
6public section.
7
8 interfaces IF_BADI_INTERFACE .
9 interfaces IF_MDG_BS_CUST_SUPP_CR_SI .
10
11 methods CONSTRUCTOR .
12protected section.
13
14 data MO_SUPPLIER type ref to CL_MDG_BS_SUPP_CR_SI_ERP_IMPL .
15private section.
16ENDCLASS.
17
18
19
20CLASS ZCL_BI_SUPP_CR_SI_ERP IMPLEMENTATION.
21
22
23 METHOD constructor.
24 CREATE OBJECT mo_supplier.
25 ENDMETHOD.
26
27
28 METHOD if_mdg_bs_cust_supp_cr_si~map_bp_to_staging_wo_cr.
29 mo_supplier->if_mdg_bs_cust_supp_cr_si~map_bp_to_staging_wo_cr(
30 EXPORTING
31 is_bp_api = is_bp_api
32 iv_temp_sta_bp_id = iv_temp_sta_bp_id
33 CHANGING
34 ct_bp_staging = ct_bp_staging
35 ct_messages = ct_messages ).
36
37
38 ENDMETHOD.
39
40
41 METHOD if_mdg_bs_cust_supp_cr_si~set_supplier_data_2_sta.
42******************************************************************************************
43*- Created By : TE579309.
44*- Created Date: 01-Aug-2024
45*- Description: This class is created to add the API structures data for custom Tables
46*- uploaded from the Consolidation file into a change Request.
47*- This method gets triggered only when Change Request activation is configured
48*- in consolidation upload.
49******************************************************************************************
50 DATA: ls_bp TYPE mdg_bs_bp_s_extern,
51 lv_bp_header TYPE bu_businesspartner,
52 ls_sta_zbp_suppl TYPE zmdgbp_s_bp_pp_zbp_suppl,
53 lt_sta_zbp_suppl TYPE TABLE OF zmdgbp_s_bp_pp_zbp_suppl,
54 ls_data_lfa1_ext TYPE zvmds_ei_vmd_ext_data,
55 r_descr TYPE REF TO cl_abap_structdescr,
56 r_descr_tmp TYPE REF TO cl_abap_structdescr,
57 wa_comp TYPE abap_compdescr,
58 wa_comp_tmp TYPE abap_compdescr,
59 lt_entities TYPE STANDARD TABLE OF usmd_entity,
60 lv_entity TYPE usmd_entity.
61
62 FIELD-SYMBOLS: <lt_data_lfa1_ext> TYPE ANY TABLE.
63
64 mo_supplier->if_mdg_bs_cust_supp_cr_si~set_supplier_data_2_sta(
65 EXPORTING
66 is_bp_api = is_bp_api
67 ir_cr_api = ir_cr_api
68 ir_gov_api = ir_gov_api
69 iv_crequest_id = iv_crequest_id
70 iv_temp_sta_bp_id = iv_temp_sta_bp_id
71 CHANGING
72 ct_return_messages = ct_return_messages ).
73
74 r_descr ?= cl_abap_typedescr=>describe_by_data( ls_data_lfa1_ext ).
75 r_descr_tmp ?= cl_abap_typedescr=>describe_by_data( ls_sta_zbp_suppl ).
76 ls_bp = is_bp_api.
77 IF ls_bp-partner-header-object_instance-bpartner IS NOT INITIAL.
78 lv_bp_header = ls_bp-partner-header-object_instance-bpartner.
79 ELSE.
80 lv_bp_header = iv_temp_sta_bp_id.
81 ENDIF.
82 ls_data_lfa1_ext = ls_bp-vendor-central_data-data.
83 IF ls_data_lfa1_ext IS NOT INITIAL.
84 LOOP AT r_descr->components INTO wa_comp.
85 READ TABLE r_descr_tmp->components INTO wa_comp_tmp WITH KEY name = wa_comp-name.
86 IF sy-subrc IS INITIAL.
87 ls_sta_zbp_suppl-(wa_comp-name) = ls_data_lfa1_ext-(wa_comp-name).
88 ELSEIF wa_comp-name = 'LIFNR'.
89 ls_sta_zbp_suppl-bp_header = lv_bp_header.
90 ls_sta_zbp_suppl-assgnm_id = if_mdg_bs_ecc_bp_constants=>gc_sp_std_mlt_assignment_id.
91 ENDIF.
92 ENDLOOP.
93 ENDIF.
94 IF ls_sta_zbp_suppl-bp_header IS NOT INITIAL.
95 APPEND 'ZBP_SUPPL' TO lt_entities[].
96 APPEND ls_sta_zbp_suppl TO lt_sta_zbp_suppl[].
97
98 LOOP AT lt_entities INTO lv_entity.
99 TRY.
100 CASE lv_entity.
101 WHEN 'ZBP_SUPPL'.
102 ASSIGN lt_sta_zbp_suppl TO <lt_data_lfa1_ext>.
103 IF <lt_data_lfa1_ext> IS ASSIGNED AND <lt_data_lfa1_ext> IS NOT INITIAL.
104 CALL METHOD ir_gov_api->write_entity
105 EXPORTING
106 iv_crequest_id = iv_crequest_id
107 iv_entity_name = lv_entity
108 it_data = <lt_data_lfa1_ext>.
109 ENDIF.
110 WHEN OTHERS.
111 ENDCASE.
112 CATCH cx_usmd_gov_api_core_error cx_usmd_gov_api.
113
114 ENDTRY.
115 ENDLOOP.
116 ENDIF.
117 ENDMETHOD.
118ENDCLASS.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- Which BAdI is used for supplier Change Request staging?
- How do I add custom table data into a supplier Change Request from consolidation upload?
- What is the implementation pattern for IF_MDG_BS_CUST_SUPP_CR_SI in supplier consolidation?
Possible questions
- Which transaction creates the BAdI implementation?
- Which methods must the supplier staging class implement?
- What does CONSTRUCTOR do in the example BAdI class?
- How is custom entity data written to the Governance API?
- When does set_supplier_data_2_sta run in consolidation?
- How do I map BP vendor data into a custom staging table?