SAP MDG · UTILITIES
How do I implement BP-to-Customer or BP-to-Vendor tax number mapping in a custom CVI mapper class?
Implement the CVI custom mapper so it reads BP tax numbers from `I_PARTNER-CENTRAL_DATA-TAXNUMBER-TAXNUMBERS`, selects the target field from `ZMDG_BP_MAP_VAT` by country and tax type, writes the value with dynamic component access, and sets the matching X-structure flag.
Implement the CVI custom mapper so it reads BP tax numbers from `I_PARTNER-CENTRAL_DATA-TAXNUMBER-TAXNUMBERS`, selects the target field from `ZMDG_BP_MAP_VAT` by country and tax type, writes the value with dynamic component access, and sets the matching X-structure flag.
Implement the CVI mapper around three rules: use the BP address country as the first filter, drive the target field from customizing table `ZMDG_BP_MAP_VAT`, and always update the related X-structure when a mapped tax field is filled or cleared. The source tax data comes from `I_PARTNER-CENTRAL_DATA-TAXNUMBER-TAXNUMBERS`, and deleted entries must be ignored with `TASK <> 'D'`.
Process flow
- Open the CVI enhancement implementation for `IF_EX_CVI_CUSTOM_MAPPER` in `SE18`.
- Determine whether the call is for customer or vendor mapping and use `ZZBP_CAT = 'CUST'` or `ZZBP_CAT = 'SUPL'` accordingly.
- Read the first BP address and derive the country filter.
- Select the relevant rows from `ZMDG_BP_MAP_VAT`.
- Loop over `I_PARTNER-CENTRAL_DATA-TAXNUMBER-TAXNUMBERS` and skip entries where `TASK = 'D'`.
- Match `DATA_KEY-TAXTYPE` to the customizing tax category.
- Write the mapped value into the target field named in `ZZFIELD_NAME` using dynamic component access.
- Set the matching X-structure field to `abap_true`. After this, test with a BP containing multiple tax numbers and multiple countries if applicable.
Referenced tables
| Object | Purpose |
|---|---|
ZMDG_BP_MAP_VAT | Customizing table that determines the target tax field and target category (`CUST` or `SUPL`) for BP tax mapping. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example: ZCL_MDGBP_CVI_CUSTOM_MAPPER_FULL.abap
Exact relevant implementation excerpt from the knowledge document set.
1class ZCL_MDGBP_CVI_CUSTOM_MAPPER definition
2 public
3 final
4 create public .
5
6public section.
7
8 interfaces IF_BADI_INTERFACE .
9 interfaces IF_EX_CVI_CUSTOM_MAPPER .
10protected section.
11private section.
12ENDCLASS.
13
14
15
16CLASS ZCL_MDGBP_CVI_CUSTOM_MAPPER IMPLEMENTATION.
17
18
19 method IF_EX_CVI_CUSTOM_MAPPER~MAP_BP_REL_TO_CUSTOMER_CONTACT.
20 RETURN.
21 endmethod.
22
23
24 method IF_EX_CVI_CUSTOM_MAPPER~MAP_BP_REL_TO_VENDOR_CONTACT.
25 RETURN.
26 endmethod.
27
28
29 METHOD if_ex_cvi_custom_mapper~map_bp_to_customer.
30***********************************************************************************************
31*Implementation: This method is implemented to Mapp the BP Tax Codes to Customer Tax fields SCT*
32* Based on the Tax code mapping Table ZMDG_BP_MAP_VAT.
33* Created by: TE579309
34* Created on: 29.08.2028
35***********************************************************************************************
36 DATA: lt_bp_tax TYPE bus_ei_bupa_taxnumber_t,
37 ls_bp_tax TYPE bus_ei_bupa_taxnumber,
38 lv_country TYPE land1,
39 lv_pattern TYPE char5,
40 lt_address TYPE bus_ei_bupa_address_t.
41 lt_address[] = i_partner-central_data-address-addresses[].
42 READ TABLE lt_address INTO DATA(ls_address) INDEX 1.
43 CONCATENATE '%' ls_address-data-postal-data-country '%' INTO lv_pattern.
44 SELECT * FROM zmdg_bp_map_vat INTO TABLE @DATA(lt_bp_map_vat) WHERE zzbp_cat = 'CUST' AND zztax_cat LIKE @lv_pattern.
45 IF sy-subrc IS INITIAL.
46 lt_bp_tax = i_partner-central_data-taxnumber-taxnumbers.
47 IF lt_bp_tax[] IS NOT INITIAL.
48 LOOP AT lt_bp_map_vat INTO DATA(ls_bp_map_vat).
49 READ TABLE lt_bp_tax INTO ls_bp_tax WITH KEY data_key-taxtype = ls_bp_map_vat-zztax_cat.
50 IF sy-subrc IS INITIAL AND ls_bp_tax-task NE 'D'.
51 IF ls_bp_tax-data_key-taxnumber IS NOT INITIAL.
52 c_customer-central_data-central-data-(ls_bp_map_vat-zzfield_name) = ls_bp_tax-data_key-taxnumber.
53 ELSE.
54 c_customer-central_data-central-data-(ls_bp_map_vat-zzfield_name) = ls_bp_tax-data_key-taxnumxl.
55 ENDIF.
56 c_customer-central_data-central-datax-(ls_bp_map_vat-zzfield_name) = abap_true.
57 ELSE.
58 c_customer-central_data-central-data-(ls_bp_map_vat-zzfield_name) = ''.
59 ENDIF.
60 c_customer-central_data-central-datax-(ls_bp_map_vat-zzfield_name) = abap_true.
61 ENDLOOP.
62 ENDIF.
63 ENDIF.
64
65 IF c_customer-central_data-central-data-brsch IS NOT INITIAL.
66 CALL METHOD zcl_mdg_cus_approvers=>get_ibc_from_ted
67 EXPORTING
68 iv_industry_code = c_customer-central_data-central-data-brsch
69 IMPORTING
70 ev_indbuscode = DATA(lv_zzwwibc).
71
72 IF lv_zzwwibc IS NOT INITIAL.
73 c_customer-central_data-central-data-zzwwibc = lv_zzwwibc.
74 c_customer-central_data-central-datax-zzwwibc = abap_true.
75 ENDIF.
76 ENDIF.
77
78* SELECT * FROM zmdg_bp_map_vat INTO TABLE @DATA(lt_bp_map_vat) WHERE zzbp_cat = 'CUST'.
79*** IF sy-subrc IS INITIAL.
80*** lt_bp_tax = i_partner-central_data-taxnumber-taxnumbers.
81*** IF lt_bp_tax[] IS NOT INITIAL.
82*** LOOP AT lt_bp_tax INTO ls_bp_tax.
83*** LOOP AT lt_bp_map_vat INTO DATA(ls_bp_map_vat).
84*** IF ls_bp_tax-data_key-taxtype CP ls_bp_map_vat-zztax_cat.
85*** IF ls_bp_tax-data_key-taxnumber IS NOT INITIAL.
86*** c_customer-central_data-central-data-(ls_bp_map_vat-zzfield_name) = ls_bp_tax-data_key-taxnumber.
87*** ELSE.
88*** c_customer-central_data-central-data-(ls_bp_map_vat-zzfield_name) = ls_bp_tax-data_key-taxnumxl.
89*** ENDIF.
90*** c_customer-central_data-central-datax-(ls_bp_map_vat-zzfield_name) = abap_true.
91*** EXIT.
92*** ENDIF.
93*** c_customer-central_data-central-datax-(ls_bp_map_vat-zzfield_name) = abap_true.
94*** ENDLOOP.
95*** ENDLOOP.
96*** ELSE.
97*** LOOP AT lt_bp_map_vat INTO ls_bp_map_vat.
98*** c_customer-central_data-central-data-(ls_bp_map_vat-zzfield_name) = ''.
99*** c_customer-central_data-central-datax-(ls_bp_map_vat-zzfield_name) = abap_true.
100*** ENDLOOP.
101*** ENDIF.
102*** ENDIF.
103 ENDMETHOD.
104
105
106 method IF_EX_CVI_CUSTOM_MAPPER~MAP_BP_TO_CUSTOMER_CONTACT.
107 RETURN.
108 endmethod.
109
110
111 METHOD if_ex_cvi_custom_mapper~map_bp_to_vendor.
112***********************************************************************************************
113*Implementation: This method is implemented to Mapp the BP Tax Codes to Vendor Tax fields SCT*
114* Based on the Tax code mapping Table ZMDG_BP_MAP_VAT.
115* Created by: TE579309
116* Created on: 29.08.2028
117***********************************************************************************************
118 DATA: lt_bp_tax TYPE bus_ei_bupa_taxnumber_t,
119 ls_bp_tax TYPE bus_ei_bupa_taxnumber,
120 lv_country TYPE land1,The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How do I map BP tax numbers into customer/vendor tax fields during CVI conversion?
- How does `IF_EX_CVI_CUSTOM_MAPPER` determine the target tax field from BP tax data?
- What customizing and ABAP logic are needed for BP tax code mapping in CVI?
Possible questions
- Which BP structure is the source for tax numbers in CVI mapping?
- How do I control customer vs vendor tax-field mapping with customizing?
- How do I skip deleted BP tax entries in a CVI mapper?
- How do I update the X-structure when filling mapped tax fields?
- How do I keep customer and vendor tax mapping symmetric?