SAP MDG · CONSOLIDATION
How do I implement a custom SAP MDG Business Partner consolidation model with custom number assignment and custom extension-table processing?
Create a custom subclass ZCL_MDC_MODEL_BP of CL_MDC_MODEL_BP and redefine MAP_BUSINESS_PARTNER_2API, MAP_EXTENSIONS_2API, READ_ALL_DATA, and SAVE_BUSINESS_PARTNER_ACTIVE. The pattern in the source assigns a generated number for grouping ZTRA, reuses the same number on rerun via ZMDG_BP_MDC_MAP, maps custom ZLFA1_EXT data dynamically into CVI API extension structures, and saves active custom-table data in update task.
Create a custom subclass ZCL_MDC_MODEL_BP of CL_MDC_MODEL_BP and redefine MAP_BUSINESS_PARTNER_2API, MAP_EXTENSIONS_2API, READ_ALL_DATA, and SAVE_BUSINESS_PARTNER_ACTIVE. The pattern in the source assigns a generated number for grouping ZTRA, reuses the same number on rerun via ZMDG_BP_MDC_MAP, maps custom ZLFA1_EXT data dynamically into CVI API extension structures, and saves active custom-table data in update task.
Use a custom BP consolidation model class `ZCL_MDC_MODEL_BP` inheriting from `CL_MDC_MODEL_BP` and implement four redefinitions: `MAP_BUSINESS_PARTNER_2API`, `MAP_EXTENSIONS_2API`, `READ_ALL_DATA`, and `SAVE_BUSINESS_PARTNER_ACTIVE`. The retrieved source shows a full pattern for ZTRA number assignment, rerun-safe mapping reuse, RTTI-based extension mapping, and update-task persistence of the custom extension table.
Process flow
- Create custom class `ZCL_MDC_MODEL_BP` inheriting from `CL_MDC_MODEL_BP`.
- Redefine `MAP_BUSINESS_PARTNER_2API` for ZTRA number assignment and reuse via `ZMDG_BP_MDC_MAP`.
- Redefine `MAP_EXTENSIONS_2API` to map `ZLFA1_EXT` PRC data into CVI API extension fields.
- Redefine `READ_ALL_DATA` to load standard process data and assign `MR_ZZLFA1_EXT_PRC` from `ZLFA1_EXT`.
- Redefine `SAVE_BUSINESS_PARTNER_ACTIVE` to persist custom extension data in update task.
- Ensure BP number resolution uses `MT_BP_KEYS` first and falls back to `BUPA_NUMBERS_GET` when needed.
- Activate the class and test rerun behavior to confirm the same `PROCESS_ID` reuses the same mapped number.
Referenced tables
| Object | Purpose |
|---|---|
ZMDG_BP_MDC_MAP | Stores process-wise mapping between source partner and generated MDG partner number for rerun/idempotency. |
ZLFA1_EXT | Custom extension table whose fields are read from staged data and persisted on activation. |
ZMDC_TT_ZZLFA1_EXT_PRC | Typed reference for staged PRC data of the custom extension table. |
BUT000_PRC | Standard staged BP process table used to derive `PROCESS_ID` and partner mapping context. |
CVI_EI_EXTERN | Standard API payload structure whose `DATA` component is enhanced with custom extension fields. |
MT_BP_KEYS | Internal mapping table used at activation time to resolve BP number from BP GUID. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1class ZCL_MDC_MODEL_BP definition
2 public
3 inheriting from CL_MDC_MODEL_BP
4 create public .
5
6public section.
7protected section.
8
9 data MR_ZZLFA1_EXT_PRC type ref to ZMDC_TT_ZZLFA1_EXT_PRC .
10
11 methods MAP_EXTENSIONS_2API
12 redefinition .
13 methods READ_ALL_DATA
14 redefinition .
15 methods SAVE_BUSINESS_PARTNER_ACTIVE
16 redefinition .
17 methods MAP_BUSINESS_PARTNER_2API
18 redefinition .
19private section.
20ENDCLASS.
21
22
23
24CLASS ZCL_MDC_MODEL_BP IMPLEMENTATION.
25
26
27 METHOD map_business_partner_2api.
28**************************************************************************************************************************
29** Change ID :
30** Created by : TE579309
31** Created date : 28-07-2026
32** Transport : DD1K906994
33** Description : This method is implemented to generat the new number and assign to the partner and Customer leve
34** for ZTRA account group.
35***************************************************************************************************************************
36 TRY.
37 CALL METHOD super->map_business_partner_2api.
38 CATCH cx_mdc_model.
39 ENDTRY.
40 FIELD-SYMBOLS: <lfs_cvis_ei_extern> TYPE cvis_ei_extern,
41 <lfs_but000_prc> TYPE but000_prc,
42 <lfs_but000_prc_tmp> TYPE but000_prc.
43 DATA: lv_partner TYPE bu_partner,
44 lv_index TYPE sy-index,
45 lv_no_map TYPE boolean,
46 lv_source_id TYPE mdc_source_id,
47 ls_map_partner TYPE zmdg_bp_mdc_map,
48 ls_map_partner_tmp TYPE zmdg_bp_mdc_map,
49 lt_map_partner TYPE TABLE OF zmdg_bp_mdc_map,
50 lt_map_partner_tmp TYPE TABLE OF zmdg_bp_mdc_map.
51* read the main But000 data coming from file.
52 READ TABLE me->mr_but000_prc->* INDEX 1 ASSIGNING <lfs_but000_prc_tmp>.
53 IF sy-subrc IS INITIAL.
54* Check if there is any Mapping in the Mapping table based on Process ID
55 SELECT * FROM zmdg_bp_mdc_map INTO TABLE lt_map_partner_tmp WHERE process_id = <lfs_but000_prc_tmp>-process_id.
56 IF sy-subrc <> 0.
57 lv_no_map = abap_true.
58 ENDIF.
59* loop on CVI_EI_EXTERNA- API data for each, generat the new number and assing to customer and BP level
60 LOOP AT me->mt_cvi_ei_extern ASSIGNING FIELD-SYMBOL(<lfs_cvi_extern>).
61 lv_index = sy-tabix.
62 CLEAR: lv_partner.
63 READ TABLE me->mr_but000_prc->* INDEX lv_index ASSIGNING <lfs_but000_prc>.
64 IF sy-subrc IS INITIAL AND <lfs_but000_prc> IS ASSIGNED.
65 ls_map_partner-process_id = <lfs_but000_prc>-process_id.
66 ls_map_partner-partner_prc = <lfs_but000_prc>-partner.
67 ASSIGN COMPONENT 'DATA' OF STRUCTURE <lfs_cvi_extern> TO <lfs_cvis_ei_extern>.
68 IF sy-subrc IS INITIAL AND <lfs_cvis_ei_extern> IS ASSIGNED AND <lfs_cvis_ei_extern>-partner-central_data-common-data-bp_control-grouping = 'ZTRA'.
69* if the control comes to this method for the first timer, there will be no mapping created for the Process ID
70 IF lv_no_map = abap_true.
71 CALL FUNCTION 'Z_NEXT_NUM_ZTRA'
72 IMPORTING
73 ex_next_bp_num = lv_partner
74 EXCEPTIONS
75 no_available_number = 1
76 number_range_error = 2
77 OTHERS = 3.
78 IF sy-subrc = 0.
79* Implement suitable error handling here
80 <lfs_cvis_ei_extern>-partner-header-object_instance-bpartner = lv_partner.
81 <lfs_cvis_ei_extern>-customer-header-object_instance-kunnr = lv_partner.
82 ls_map_partner-partner_mdg = lv_partner.
83 APPEND ls_map_partner TO lt_map_partner[].
84 CLEAR: ls_map_partner.
85 ENDIF.
86 ELSE.
87* if there is a mpping whihc means the number generation was already execudted before for this process ID.
88* read them and assign the same to Business Partner and Customer number
89 READ TABLE lt_map_partner_tmp INTO ls_map_partner_tmp WITH KEY partner_prc = <lfs_but000_prc>-partner
90 process_id = <lfs_but000_prc>-process_id.
91 IF sy-subrc = 0.
92 CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
93 EXPORTING
94 input = ls_map_partner_tmp-partner_mdg
95 IMPORTING
96 output = ls_map_partner_tmp-partner_mdg.
97 <lfs_cvis_ei_extern>-partner-header-object_instance-bpartner = ls_map_partner_tmp-partner_mdg.
98 <lfs_cvis_ei_extern>-customer-header-object_instance-kunnr = ls_map_partner_tmp-partner_mdg.
99 ENDIF.
100 ENDIF.
101 ENDIF.
102 ENDIF.
103 ENDLOOP.
104* in the first run, this internal table will be filled with the new number, source id and the process ID.
105* update it in to the custom table created for the mapping
106 IF lt_map_partner[] IS NOT INITIAL.
107 MODIFY zmdg_bp_mdc_map FROM TABLE lt_map_partner[].
108 IF sy-subrc IS INITIAL.
109 CLEAR: lt_map_partner[].
110 ENDIF.
111 ENDIF.
112 ENDIF.
113 ENDMETHOD.
114
115
116 METHOD map_extensions_2api.
117******************************************************************************************
118*- Created By : TE579309.
119*- Created Date: 01-Aug-2024
120*- Description: This class is created by Inheriting class CL_MDC_MODEL_BP and redefiningThe remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How do I extend the Business Partner MDG model for custom table handling?
- How do I implement MAP_BUSINESS_PARTNER_2API, MAP_EXTENSIONS_2API, READ_ALL_DATA, and SAVE_BUSINESS_PARTNER_ACTIVE for a custom BP model?
- How do I persist custom BP extension data during consolidation and direct activation?
Possible questions
- Which class should I inherit for a custom BP consolidation model?
- How do I assign a generated BP/customer number only for grouping ZTRA?
- How do I map a custom PRC table into CVI API extension data?
- How do I read custom source data into MDG model processing?
- How do I save custom extension data in update task during direct activation?