This blog is based on S/4HANA OP1610 release and relevant as well for subsequent releases of S/4HANA.
This blog is aimed to show 2 ways how to control Business Partner grouping based on role/role grouping selection at Business Partner creation.
- using customizing in Customer-Vendor-Integration mapping
- using a custom table
Business Partner transaction BP as a single point of entry to maintain customer/vendor master data, gives the possibility to have defined several Business Partner Groupings in customizing. It’s quite difficult for a user to choose the right Business Partner Grouping which is usable for Customer/Vendor roles and Customer Vendor Integration (CVI) linkage.
For both variants a BAdI implementation of BAdI BUPA_NUMBER_GROUP is used.
An additional BAdI is available now to control BP roles and BP groupings.
2571755 – Provision to influence Business Partner roles in Business Partner transaction
Using Customizing in Customer-Vendor-Integration mapping
Usually not all Business Partner Groupings are relvant for Customer-Vendor-Integration. This solution is using mapping tables CVIC_VEND_TO_BP2 and CVIC_CUST_TO_BP2 at IMG: Cross-Application Components -> Master Data Synchronization -> Customer/Vendor Integration -> Business Partner Settings ->
For Vendor: Settings for Customer Integration -> Settings for Vendor Integration -> Define BP Role for Direction Vendor to BP
For Customer: Define BP Role for Direction Customer to BP
to determine Customer/Vendor Account Groups assigned to roles. This setup is basically done for synchronization direction Customer/Vendor -> Business Partner.
With determined Account Groups mapping table TBC001 from IMG path
For Customer: Field Assignment for Customer Integration -> Assign Keys -> Define Number Assignment for Direction BP to Customer
For Vendor: Field Assignment for Vendor Integration -> Assign Keys -> Define Number Assignment for Direction BP to Vendor
is used to determine CVI (Customer-Vendor-Integration) relevant Business Partner Groupings.
Enclosed you will find an example coding for such a BAdI-Implementation.
DATA: lv_bu_group TYPE bu_group, ls_bus_roles TYPE bus_roles, lt_cvic_vend_to_bp2 TYPE TABLE OF cvic_vend_to_bp2, ls_cvic_vend_to_bp2 TYPE cvic_vend_to_bp2, lt_cvic_cust_to_bp2 TYPE TABLE OF cvic_cust_to_bp2, ls_cvic_cust_to_bp2 TYPE cvic_cust_to_bp2, ls_dropdown_values TYPE bus_screen_dropdown_value, lv_grouping TYPE bu_group, lv_sytabix TYPE sy-tabix, lt_tb003i TYPE TABLE OF tb003i, ls_tb003i TYPE tb003i, ls_tbd001 TYPE tbd001, ls_tbc001 TYPE tbc001, lv_line TYPE i. * check if grouping is correct in case of BP creation IF iv_request->gs_navigation-bupa-activity EQ iv_request->gc_activity_create. "creation * get selected grouping lv_bu_group = iv_request->gs_navigation-bupa-creation_group. * get selected role ls_bus_roles = iv_request->gs_navigation-bupa-partner_role. IF ls_bus_roles-is_group EQ 'X'. * role grouping SELECT * FROM tb003i INTO TABLE lt_tb003i WHERE rltgr EQ ls_bus_roles-role. * get possible account groups vendor LOOP AT lt_tb003i INTO ls_tb003i. SELECT * FROM cvic_vend_to_bp2 APPENDING TABLE lt_cvic_vend_to_bp2 WHERE role = ls_tb003i-role. ENDLOOP. ELSE. * get possible account groups vendor SELECT * FROM cvic_vend_to_bp2 INTO TABLE lt_cvic_vend_to_bp2 WHERE role = ls_bus_roles-role. ENDIF. IF NOT lt_cvic_vend_to_bp2 IS INITIAL. LOOP AT et_dropdown_values INTO ls_dropdown_values. lv_sytabix = sy-tabix. * get grouping LOOP AT lt_cvic_vend_to_bp2 INTO ls_cvic_vend_to_bp2. CLEAR: ls_tbc001, lv_grouping. SELECT SINGLE * FROM tbc001 INTO ls_tbc001 WHERE ktokk = ls_cvic_vend_to_bp2-account_group. lv_grouping = ls_dropdown_values-key. IF ls_tbc001-bu_group NE lv_grouping. DELETE et_dropdown_values INDEX lv_sytabix. EXIT. ELSE. lv_sytabix = lv_sytabix + 1. ENDIF. ENDLOOP. ENDLOOP. ELSE. IF ls_bus_roles-is_group EQ 'X'. * get possible account groups customer LOOP AT lt_tb003i INTO ls_tb003i. SELECT * FROM cvic_cust_to_bp2 APPENDING TABLE lt_cvic_cust_to_bp2 WHERE role = ls_tb003i-role. ENDLOOP. ELSE. * get possible account groups customer SELECT * FROM cvic_cust_to_bp2 INTO TABLE lt_cvic_cust_to_bp2 WHERE role = ls_bus_roles-role. ENDIF. IF NOT lt_cvic_cust_to_bp2 IS INITIAL. LOOP AT et_dropdown_values INTO ls_dropdown_values. lv_sytabix = sy-tabix. * get grouping LOOP AT lt_cvic_cust_to_bp2 INTO ls_cvic_cust_to_bp2. CLEAR: ls_tbd001, lv_grouping. SELECT SINGLE * FROM tbd001 INTO ls_tbd001 WHERE ktokd = ls_cvic_cust_to_bp2-account_group. lv_grouping = ls_dropdown_values-key. IF ls_tbd001-bu_group NE lv_grouping. DELETE et_dropdown_values INDEX lv_sytabix. EXIT. ELSE. lv_sytabix = lv_sytabix + 1. ENDIF. ENDLOOP. ENDLOOP. ENDIF. ENDIF. * set grouping DESCRIBE TABLE et_dropdown_values LINES lv_line. IF lv_line EQ 1. CLEAR: ls_dropdown_values. READ TABLE et_dropdown_values INTO ls_dropdown_values INDEX 1. iv_request->gs_navigation-bupa-creation_group = ls_dropdown_values-key. ENDIF. ENDIF.
Instead of using Mapping customizing you can use your own customizing table where you just store role Business Partner Grouping assingment and replace Customizing table logic in given code example by your Z-table.
By selecting a Customer/Vendor specific role in Business Partner creation, the system will list CVI relevant Business Partner Groupings only.
With friendly support of Michael Schmitz and Dr. Alois Hornig from MTU Aero Engines AG