SAP MDG · CONSOLIDATION
How do I implement custom BP consolidation logic in ZCL_MDC_MODEL_BP for numbering, extension mapping, and active-table persistence?
Create ZCL_MDC_MODEL_BP as a subclass of CL_MDC_MODEL_BP and redefine MAP_BUSINESS_PARTNER_2API, MAP_EXTENSIONS_2API, READ_ALL_DATA, and SAVE_BUSINESS_PARTNER_ACTIVE. Use ZMDG_BP_MDC_MAP for idempotent BP/KUNNR number reuse, map custom staged data from ZLFA1_EXT dynamically into the API, and persist active custom fields with Z_BP_ZLFA1_EXT_UPDATE in update task.
Create ZCL_MDC_MODEL_BP as a subclass of CL_MDC_MODEL_BP and redefine MAP_BUSINESS_PARTNER_2API, MAP_EXTENSIONS_2API, READ_ALL_DATA, and SAVE_BUSINESS_PARTNER_ACTIVE. Use ZMDG_BP_MDC_MAP for idempotent BP/KUNNR number reuse, map custom staged data from ZLFA1_EXT dynamically into the API, and persist active custom fields with Z_BP_ZLFA1_EXT_UPDATE in update task.
Implement ZCL_MDC_MODEL_BP as a custom subclass of CL_MDC_MODEL_BP for BP consolidation. The documented pattern is: read staged data, map BP/customer payload with controlled numbering for grouping ZTRA, map custom extension data from ZLFA1_EXT into the API, then persist active records in an update task using Z_BP_ZLFA1_EXT_UPDATE.
Process flow
- Create `ZCL_MDC_MODEL_BP` inheriting from `CL_MDC_MODEL_BP`.
- Redefine `MAP_BUSINESS_PARTNER_2API`, `MAP_EXTENSIONS_2API`, `READ_ALL_DATA`, and `SAVE_BUSINESS_PARTNER_ACTIVE`.
- In `MAP_BUSINESS_PARTNER_2API`, read the first `BUT000` process record from `MR_BUT000_PRC`.
- Check `ZMDG_BP_MDC_MAP` by `PROCESS_ID` before generating a new number.
- If grouping is `ZTRA` and no mapping exists, call `Z_NEXT_NUM_ZTRA`.
- Assign the same number to BP and customer header objects.
- In `MAP_EXTENSIONS_2API`, read `ZLFA1_EXT` staged records for the current `PROCESS_KEY`.
- Use RTTI-based dynamic assignment to fill API `DATA` and `DATAX` fields and keep `LIFNR` aligned with the API context.','In `READ_ALL_DATA`, call the superclass and load `ZLFA1_EXT` into `MR_ZZLFA1_EXT_PRC`.','In `SAVE_BUSINESS_PARTNER_ACTI
Referenced tables
| Object | Purpose |
|---|---|
ZMDG_BP_MDC_MAP | Stores process-level BP number mappings so reruns can reuse the same BP/customer number. |
ZLFA1_EXT | Custom extension table whose fields are read from staging and persisted during active save. |
MR_BUT000_PRC | Process-level staged BP source data used to determine grouping and process identity. |
MR_ZZLFA1_EXT_PRC | Typed reference for the custom staged source table in the model class. |
MT_CVI_EI_EXTERN | API payload collection used for extension mapping and active-save processing. |
MT_BP_KEYS | BP key mapping collection used to resolve the BP number from the current process context. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example: ZCL_BI_CUST_CR_SI_ERP.clas.abap
Exact relevant implementation excerpt from the knowledge document set.
1class ZCL_BI_CUST_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_CUSTOMER type ref to CL_MDG_BS_CUST_CR_SI_ERP_IMPL .
15private section.
16ENDCLASS.
17
18
19
20CLASS ZCL_BI_CUST_CR_SI_ERP IMPLEMENTATION.
21
22
23 METHOD constructor.
24 CREATE OBJECT mo_customer.
25 ENDMETHOD.
26
27
28 method IF_MDG_BS_CUST_SUPP_CR_SI~MAP_BP_TO_STAGING_WO_CR.
29 mo_customer->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 endmethod.
37
38
39 METHOD if_mdg_bs_cust_supp_cr_si~set_supplier_data_2_sta.
40
41 mo_customer->if_mdg_bs_cust_supp_cr_si~set_supplier_data_2_sta(
42 EXPORTING
43 is_bp_api = is_bp_api
44 ir_cr_api = ir_cr_api
45 ir_gov_api = ir_gov_api
46 iv_crequest_id = iv_crequest_id
47 iv_temp_sta_bp_id = iv_temp_sta_bp_id
48 CHANGING
49 ct_return_messages = ct_return_messages ).
50 ENDMETHOD.
51ENDCLASS.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How do I enhance CL_MDC_MODEL_BP with custom partner numbering and extension-table save logic?
- How is custom data mapped in BP consolidation model class ZCL_MDC_MODEL_BP?
- How do I persist custom BP extension data during MDC activation?
Possible questions
- Which superclass does ZCL_MDC_MODEL_BP inherit from?
- Which methods must I redefine in ZCL_MDC_MODEL_BP?
- How does MAP_BUSINESS_PARTNER_2API work for ZTRA?
- How does MAP_EXTENSIONS_2API map custom fields dynamically?
- How is ZLFA1_EXT saved during activation?
- Which function modules are used for BP number mapping and update-task save?