Only the commonly used BAPIs are listed. You can find more usages in specific function groups; roles can be directly maintained when they are created, or maintained separately; those that cannot find BAPIs, such as company codes, use APIs to maintain them.
BAPI list
Create BP
BAPI
Features
BAPI_BUPA_CREATE_FROM_DATA
Create BP, including central data, address, etc.
BAPI_BUPA_FS_CREATE_FROM_DATA2
Same function as above, one more role assignment function
Role maintenance
BAPI
Features
BAPI_BUPA_ROLES_GET_2
Get assigned Role (by date)
BAPI_BUPA_ROLE_ADD_2
Add Role
BAPI_BUPA_ROLE_CHANGE
Modify existing Role attributes
BAPI_BUPA_ROLE_EXIST_CHECK_2
Verify the existence of Role
BAPI_BUPA_ROLE_REMOVE
Delete assigned Role
Central data maintenance
BAPI
Features
BAPI_BUPA_CENTRAL_GETDETAIL
Get central data
BAPI_BUPA_CENTRAL_CHANGE
Modify central data
Address information maintenance
BAPI
Features
BAPI_BUPA_ADDRESSES_GET
Get all address information
BAPI_BUPA_ADDRESS_ADD
Add address information
BAPI_BUPA_ADDRESS_CHANGE
Modify existing address information
BAPI_BUPA_ADDRESS_GETDETAIL
Get detailed information about an address
BAPI_BUPA_ADDRESS_GET_NUMBERS
Get the address number corresponding to the address
BAPI_BUPA_ADDRESS_REMOVE
Delete address information
Bank information maintenance
BAPI
Features
BAPI_BUPA_BANKDETAILS_GET
Get all bank information
BAPI_BUPA_BANKDETAIL_ADD
Add bank information
BAPI_BUPA_BANKDETAIL_CHANGE
Modify bank information
BAPI_BUPA_BANKDETAIL_GETDETAIL
Get details of a single bank
BAPI_BUPA_BANKDETAIL_NUMBERS
Get bank ID
BAPI_BUPA_BANKDETAIL_REMOVE
Delete bank information
Identification Number (Identification Number/Certificate Number)
BAPI
Features
BAPI_IDENTIFICATIONDETAILS_GET
Get all identification numbers
BAPI_IDENTIFICATION_GET_DETAIL
Get details of a single identification number
BAPI_IDENTIFICATION_ADD
Add identification number
BAPI_IDENTIFICATION_CHANGE
Modify the identification number
BAPI_IDENTIFICATION_REMOVE
Delete identification number
API
API
Features
CMD_EI_API_EXTRACT
Read BP customer information
VMD_EI_API_EXTRACT
Read BP supplier information
VMD_EI_API
Maintain BP suppliers
CMD_EI_API
Maintain BP customers
Enhance
Badi
Features
PARTNER_UPDATE
BP created or modified
ADDRESS_UPDATE
BP address (communication) data maintenance
API sample code (maintain company code)
Maintain customers
form maintain_cust_company using u_bp_basic type zsmdg_bp_input_basic_req
u_bp_comp_tab type zmdg_bp_input_company_req_t
changing c_return_table type bapiret2_tab.
"获取BP关联的客户编码,默认1对1select single partner,
b~partner_guid,
customer
from but000 as b
innerjoin cvi_cust_link as c
on c~partner_guid eq b~partner_guid
where partner eq @u_bp_basic-bp_header
into@data(ls_bp_cust).data:ls_master_data type cmds_ei_main,
ls_customer type cmds_ei_extern,
ls_central type cmds_ei_cmd_central,
ls_company type cmds_ei_company,
lt_company type cmds_ei_company_t,
ls_message type cvis_message.
clear ls_master_data.
clear ls_customer.loop at u_bp_comp_tab intodata(ls_bp_comp).
ls_company-task ='M'.
ls_company-data_key-bukrs = ls_bp_comp-company.
ls_company-data-akont ='1122010000'.
ls_company-data-loevm = ls_bp_comp-loevm_b.
ls_company-datax-akont = abap_true.
ls_company-datax-loevm = abap_true.
append ls_company to lt_company.
endloop.
ls_central-data-ktokd ='DEBI'.
ls_central-datax-ktokd = abap_true.
ls_customer =value#(
header =value#(
object_instance =value#( kunnr = ls_bp_cust-customer )
object_task ='M')
central_data =value#(
central = ls_central
address =value#( postal = value #( data = value #(
name = u_bp_basic-zzbpnm
city = u_bp_basic-zzcity
country = u_bp_basic-ref_posta
langu ='1')
datax =value#(
name = abap_true
city = abap_true
country = abap_true
langu = abap_true
))))
company_data =value#( company = lt_company current_state = abap_true )).
append ls_customer to ls_master_data-customers.
cmd_ei_api=>initialize().
cmd_ei_api=>lock( iv_kunnr = ls_bp_cust-customer ).
cmd_ei_api=>maintain(
exporting
is_master_data = ls_master_data
importing
es_error = ls_message
).
cmd_ei_api=>unlock( iv_kunnr = ls_bp_cust-customer ).readtable ls_message-messages transporting nofieldswithkeytype='E'.if sy-subrc ne 0.callfunction'BAPI_TRANSACTION_COMMIT'
exporting
wait = abap_true.else.callfunction'BAPI_TRANSACTION_ROLLBACK'.
endif.
append linesof ls_message-messages to c_return_table.
endform.
Maintenance supplier
form maintain_ven_company using u_bp_basic type zsmdg_bp_input_basic_req
u_bp_comp_tab type zmdg_bp_input_company_req_t
changing c_return_table type bapiret2_tab.
"获取BP关联的供应商编码,默认1对1select single partner,
b~partner_guid,
vendor
from but000 as b
innerjoin cvi_vend_link as v
on v~partner_guid eq b~partner_guid
where partner eq @u_bp_basic-bp_header
into@data(ls_bp_vend).data:ls_master_data type vmds_ei_main,
ls_vendor type vmds_ei_extern,
ls_company type vmds_ei_company,
lt_company type vmds_ei_company_t,
ls_central type vmds_ei_vmd_central,
ls_message type cvis_message.
clear ls_master_data.
clear ls_vendor.loop at u_bp_comp_tab intodata(ls_bp_comp).
ls_company-task ='M'.
ls_company-data_key-bukrs = ls_bp_comp-company.
ls_company-data-akont ='2202020000'.
ls_company-data-loevm = ls_bp_comp-loevm_b.
ls_company-datax-akont = abap_true.
ls_company-datax-loevm = abap_true.
append ls_company to lt_company.
endloop.
ls_central-data-ktokk ='KRED'.
ls_central-datax-ktokk = abap_true.
ls_vendor =value#(
header =value#(
object_instance =value#( lifnr = ls_bp_vend-vendor )
object_task ='M')
central_data =value#(
central = ls_central
address =value#( postal = value #( data = value #(
name = u_bp_basic-zzbpnm
city = u_bp_basic-zzcity
country = u_bp_basic-ref_posta
langu ='1')
datax =value#(
name = abap_true
city = abap_true
country = abap_true
langu = abap_true
))))
company_data =value#( company = lt_company current_state = abap_true )).
append ls_vendor to ls_master_data-vendors.
vmd_ei_api=>initialize().
vmd_ei_api=>lock( iv_lifnr = ls_bp_vend-vendor ).
vmd_ei_api=>maintain(
exporting
is_master_data = ls_master_data
importing
es_error = ls_message
).
vmd_ei_api=>unlock( iv_lifnr = ls_bp_vend-vendor ).readtable ls_message-messages transporting nofieldswithkeytype='E'.if sy-subrc ne 0.callfunction'BAPI_TRANSACTION_COMMIT'
exporting
wait = abap_true.else.callfunction'BAPI_TRANSACTION_ROLLBACK'.
endif.
append linesof ls_message-messages to c_return_table.
endform.
Remarks
If multiple BAPIs are used continuously, it seems to be committed separately, such as creating BP's central data first, and then assigning maintenance addresses, roles, maintaining banks, and maintaining company codes in order. If there is an error in the intermediate steps, you can consider stopping or skipping. After the wrong step, proceed to the next step.