Sub topic 8
Customer/Vendor Integration: Linking Partners to Customers and Suppliers
This chapter assumes you know the business partner categories, roles, groupings and number ranges from the earlier chapters. It also assumes you can read basic ABAP Open SQL. Here you will learn how Customer/Vendor Integration (CVI) turns a business partner into the customer and supplier records that sales, purchasing and accounting still use.
Why CVI exists
Many S/4HANA processes still read the classic tables. Sales orders read customer data in KNA1, KNB1 and KNVV. Purchasing and payables read supplier data in LFA1, LFB1 and LFM1. Those tables were not removed. The business partner became the leading object, and CVI is the synchronization layer that keeps the classic tables filled.
CVI is not a copy job that you run now and then. It runs inside the save of a business partner. You maintain the partner, and CVI creates or updates the customer or supplier behind it.
What CVI keeps in sync
CVI works in two directions.
- Business partner to customer or supplier. This is the normal direction in S/4HANA. You save a partner that has a customer or supplier role, and CVI writes the classic records.
- Customer or supplier to business partner. This direction is mainly used during migration. It creates partners from existing customers and suppliers. Direct creation through the old customer and supplier transactions is blocked in S/4HANA.
CVI stores the connection in two link tables.
| Table | Key fields | Meaning |
|---|---|---|
| BUT000 | PARTNER, PARTNER_GUID | Business partner header. The GUID is the technical key. |
| CVI_CUST_LINK | PARTNER_GUID, CUSTOMER | Links a partner to one customer number. |
| CVI_VEND_LINK | PARTNER_GUID, VENDOR | Links a partner to one supplier number. |
| KNA1 / LFA1 | KUNNR / LIFNR | Classic general data for customer and supplier. |
The link uses the GUID, not the visible partner number. The customer number and the partner number can therefore differ. In practice most projects configure number ranges so that the numbers are identical, because it avoids confusion. The ranges are set in customizing, so check what your system does.
What happens when you save a partner
The sequence below shows a partner with a customer role being saved in transaction BP.
The partner and the customer are saved in the same database transaction. If CVI raises an error, such as a missing mapping or a number conflict, the save is rejected and nothing is written. You do not end up with a half-created partner.
What drives the mapping
CVI reads its decisions from customizing. At overview level, four settings matter.
- Role mapping. A business partner role is assigned to a customer or supplier role category. For example, FLCU00 (FI customer) and FLCU01 (customer) lead to customer records. FLVN00 (FI supplier) and FLVN01 (supplier) lead to supplier records. A partner with no mapped role produces no customer or supplier.
- Grouping to account group. The grouping you choose when creating the partner decides which customer or supplier account group is used. Account groups carry the field status and number range rules of the classic object.
- Number assignment. For each grouping, customizing says whether the customer or supplier number is taken from the partner number or drawn from its own range. Both ranges must be compatible.
- Field assignment. Fields such as name, address and tax numbers are mapped between partner and customer or supplier structures by mapping classes. Custom fields need an extension of these mappings.
The exact IMG activity names differ between releases. They sit under the master data synchronization and CVI settings. The next chapters cover them in detail.
Reading the link tables
The customer link query below is the basic building block for any check. It lists the customer number for each organization partner.
SELECT b~partner, c~customer
FROM but000 AS b
INNER JOIN cvi_cust_link AS c
ON c~partner_guid = b~partner_guid
WHERE b~type = '2'
INTO TABLE @DATA(lt_customers)
UP TO 10 ROWS.This is useful for verifying that a partner and its customer are connected. The more valuable query finds partners where the link is missing. It looks for partners that hold the FI customer role but have no row in the link table.
REPORT z_cvi_customer_gaps.
SELECT b~partner
FROM but000 AS b
INNER JOIN but100 AS r
ON r~partner = b~partner
LEFT OUTER JOIN cvi_cust_link AS c
ON c~partner_guid = b~partner_guid
WHERE r~rltyp = 'FLCU00'
AND c~customer IS NULL
INTO TABLE @DATA(lt_gaps)
UP TO 50 ROWS.
IF lt_gaps IS INITIAL.
WRITE / 'No FLCU00 partners without a customer link found.'.
ELSE.
LOOP AT lt_gaps INTO DATA(ls_gap).
WRITE / ls_gap-partner.
ENDLOOP.
ENDIF.The same pattern works for suppliers with CVIVENDLINK and the role FLVN00. Rows returned by this report usually point to data loaded through a path that bypassed CVI, or to a synchronization that was not active at the time.
The released OData service exposes the result of CVI. The request below returns the Customer and Supplier keys with each organization partner. Empty values mean that no link exists for that side.
GET /sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner?$filter=BusinessPartnerCategory eq '2'&$select=BusinessPartner,BusinessPartnerFullName,BusinessPartnerGrouping,Customer,Supplier&$top=5
Accept: application/jsonCommon errors and what they mean
| Symptom | Likely cause |
|---|---|
| Saving a partner with a customer role fails with a number error | The grouping's number range does not match the customer number range, or the external number is already used. |
| Role can be added, but no customer appears | The role is not mapped to a customer role category, or the role is not a customer role at all. |
| Customer exists in KNA1 but has no partner | The customer was loaded directly into the table, bypassing CVI. |
| Field is maintained in BP but not in the customer | The field is missing from the field assignment, or it is a custom field. |
| Save fails with a missing account group message | The grouping has no assigned account group for the customer or supplier direction. |
Gotchas
- Do not write to KNA1 or LFA1 directly. The link table is not updated, and the next synchronization can overwrite or conflict with your change. Use the BP transaction, the released API or the CVI-aware migration tools.
- The link is one to one per object type. One partner points to one customer and one supplier at most. A partner can be both. The dual role is covered in a later chapter.
- Activation matters. After a system conversion, the synchronization must be active and the customizing complete before users create partners. If it is not, you get the gaps found by the report above.
- Number ranges are the most frequent source of conflict. Check the partner range and the customer or supplier range together, never one alone.
Exercise
A business partner with grouping BP02 and role FLCU00 saves successfully, but a query joining BUT000 to CVICUSTLINK returns no row for it. Name two possible causes and say which table you would check first.
Show answer
Possible causes are that the partner was saved while synchronization was not active, or that the partner was loaded by a path that bypassed CVI. Check BUT100 first to confirm that the role FLCU00 is really assigned, then check the role mapping and synchronization customizing. A third cause is that the customer exists in KNA1 but the link was never created.
Exercise
Why does CVI join BUT000 and CVICUSTLINK on PARTNER_GUID and not on the partner number?
Show answer
The GUID is the technical key of the partner. The customer number and the partner number are independent values that can differ, so the link cannot rely on them being equal.