SAP MDG · UTILITIES
How do I update Business Partner data with CL_MD_BP_MAINTAIN in SAP MDG / CVI?
Use `CL_MD_BP_MAINTAIN=>maintain` with a `cvis_ei_extern_t` payload, set the BP header `object_instance-bpartner` and `object_task`, fill the relevant substructures such as central address data, then evaluate `bapirettab` and commit only in a real update scenario.
Use `CL_MD_BP_MAINTAIN=>maintain` with a `cvis_ei_extern_t` payload, set the BP header `object_instance-bpartner` and `object_task`, fill the relevant substructures such as central address data, then evaluate `bapirettab` and commit only in a real update scenario.
Use `cl_md_bp_maintain=>maintain` with a `cvis_ei_extern_t` payload. The source example updates the BP header, fills central postal address data, calls the API, and then loops through `bapirettab` to display returned messages before committing in a real update scenario.
Process flow
- Create a `cvis_ei_extern_t` table for the BP update payload.
- Append one `cvis_ei_extern` row and set `partner-header-object_instance-bpartner`.
- Set `partner-header-object_task` to `M` for modify.
- Append the required business node, for example `partner-central_data-address-addresses`.
- Fill the address task and postal fields such as city, postal code, and street.
- Call `cl_md_bp_maintain=>maintain` with the prepared payload.
- Loop over `bapirettab` and process the returned messages.
- Execute `COMMIT WORK` only for a real update scenario.
Referenced tables
| Object | Purpose |
|---|---|
cvis_ei_extern_t | Table type for the BP maintenance payload. |
cvis_ei_extern | Single BP maintenance payload structure. |
bapirettab | Return table used to read messages from the BP maintenance call. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1REPORT zbp_data_update_with_cl_md_bp_main.
2
3" ----------------------------------------------------------------------
4" Purpose:
5" Generic example showing how to update Business Partner data with
6" cl_md_bp_maintain=>maintain.
7" ----------------------------------------------------------------------
8
9DATA lt_bp_data TYPE cvis_ei_extern_t.
10DATA lt_return TYPE bapirettab.
11DATA ls_bp_data TYPE cvis_ei_extern.
12
13" Create one BP update payload.
14APPEND INITIAL LINE TO lt_bp_data ASSIGNING FIELD-SYMBOL(<bp_data>).
15IF <bp_data> IS ASSIGNED.
16 <bp_data>-partner-header-object_instance-bpartner = '0000001234'.
17 <bp_data>-partner-header-object_task = 'M'.
18
19 " Example: update the central postal address.
20 APPEND INITIAL LINE TO <bp_data>-partner-central_data-address-addresses ASSIGNING FIELD-SYMBOL(<bp_address>).
21 IF <bp_address> IS ASSIGNED.
22 <bp_address>-task = 'M'.
23 <bp_address>-data-postal-city = 'DEMO CITY'.
24 <bp_address>-data-postal-postl_cod1 = '10000'.
25 <bp_address>-data-postal-street = 'Demo Street 1'.
26
27 " Mark address fields as changed.
28 <bp_address>-data-postal-city = 'DEMO CITY'.
29 <bp_address>-data-postal-street = 'Demo Street 1'.
30 ENDIF.
31ENDIF.
32
33" Call the BP maintenance API.
34cl_md_bp_maintain=>maintain(
35 EXPORTING
36 i_data = lt_bp_data
37 IMPORTING
38 e_return = lt_return
39).
40
41" Simple message handling.
42LOOP AT lt_return ASSIGNING FIELD-SYMBOL(<return_line>).
43 LOOP AT <return_line>-object_msg ASSIGNING FIELD-SYMBOL(<message_line>).
44 WRITE: / <message_line>-type, <message_line>-message.
45 ENDLOOP.
46ENDLOOP.
47
48" Commit only in a real update scenario.
49COMMIT WORK.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I maintain Business Partner address data with CL_MD_BP_MAINTAIN?
- What is the correct ABAP pattern for BP updates using CL_MD_BP_MAINTAIN?
- How do I prepare a BP payload and call CL_MD_BP_MAINTAIN=>maintain?
Possible questions
- How do I update Business Partner data with CL_MD_BP_MAINTAIN in SAP MDG / CVI?
- How can I maintain BP central address data in ABAP?
- What is the supported API for same-system BP creation/update?
- How do I build the C_VIS payload for CL_MD_BP_MAINTAIN?
- Which transactions are used for CVI checks and BP synchronization?