Sub topic 3
Master data: customers, materials and conditions
Master data is the long-lived reference data that every sales order reads. A sales order copies values from it, so errors in master data show up in every document that follows. This chapter covers the three kinds that matter most for order-to-cash: customers, materials and pricing conditions.
This chapter assumes you know the organizational units from the previous chapter (company code, sales organization, distribution channel, division, plant). It also assumes you can read basic SQL and ABAP SELECT statements.
How master data feeds the sales order
When you enter a sold-to party and a material on an order, the system reads master data and copies values into the order. It copies payment terms, shipping conditions, item category group, tax data and price.
Customer master and the Business Partner
In S/4HANA the Business Partner (BP) is the leading object. You create customers with transaction BP, not the older XD01. Each customer is a business partner with the customer role (FLCU00 for FI data, FLCU01 for sales data). Master data synchronization, called Customer/Vendor Integration (CVI), creates the classic customer record and keeps it in step with the BP.
A customer holds data at three levels:
| Level | Key | Typical content | Main table |
|---|---|---|---|
| General | Customer number | Name, address, tax numbers, partner data | `KNA1` |
| Company code | Customer + company code | Reconciliation account, payment terms, dunning | `KNB1` |
| Sales area | Customer + sales org + distribution channel + division | Pricing procedure, shipping conditions, incoterms, partner functions | `KNVV` |
A customer can be sold to in a sales area only if it has sales area data for it. If the order screen says the customer is not defined for that sales area, the KNVV row is usually missing.
Three sales area fields affect the order directly:
- Customer pricing procedure (
KALKS) selects the pricing procedure, together with the sales area and the order type. - Customer group (
KDGRP) can be used as a key in condition records, for example for group discounts. - Partner functions define who the sold-to, ship-to, bill-to and payer are. One customer can use different partners for each role. A payer who differs from the sold-to party is common.
The customer pricing procedure is a classification code, not the procedure itself. The system combines it with a document pricing procedure from the order type to pick the final procedure.
Mapping the BP to the customer
The link between a BP and a customer is stored in CVI_CUST_LINK. In a standard setup the BP number and the customer number are the same, but the link table is the reliable way to resolve them.
Material master
The material master describes what you sell. It is organized in views, and the order process reads several of them:
- Basic data (
MARA): material type (MTART), material group (MATKL), base unit of measure (MEINS), weights. - Sales organization data (
MVKE): the sales and distribution channel level. It holds the item category group (MTPOS), the material pricing group (KONDM) and the delivering plant (DWERK). - Plant data (
MARC): availability check group, MRP settings and loading group. - Accounting data (
MBEW): valuation class and price control. This view later decides which accounts goods issue posts to.
Three fields connect directly to later chapters:
- The item category group (
MTPOS) and the order type determine the item category in the sales order. This controls whether an item is priced, schedulable or relevant for delivery. - The availability check group on the plant view controls how the availability check runs.
- The valuation class links goods issue to G/L accounts during account determination.
A material can be sold only if its sales organization view exists for the sales organization and distribution channel of the order. A material that exists but has no MVKE row for the sales area does not appear on the order.
Querying customer and material data
The following code reads the sales area data of one customer, using the BP link, and the sales data of one material. Both are read-only checks you can compare with the BP and MM03 screens.
DATA(lv_kunnr) = CONV kunnr( '0000001000' ).
DATA(lv_matnr) = CONV matnr( 'FG-100' ).
SELECT l~customer, b~partner, b~bu_group,
v~vkorg, v~vtweg, v~spart, v~kdgrp, v~kalks, v~waers
FROM cvi_cust_link AS l
INNER JOIN but000 AS b ON b~partner_guid = l~partner_guid
INNER JOIN knvv AS v ON v~kunnr = l~customer
WHERE l~customer = @lv_kunnr
INTO TABLE @DATA(lt_customer).
SELECT matnr, vkorg, vtweg, dwerk, kondm, mtpos
FROM mvke
WHERE matnr = @lv_matnr
INTO TABLE @DATA(lt_material_sales).Material numbers are stored internally in the format of the system. Depending on the system's conversion exit and length, a number like FG-100 can need padding or a different format. Check the number on the MM03 screen first.
Condition master data
A condition record stores a price, discount, surcharge or tax rate under a key. Conditions are the master data of pricing. The next chapter explains how the condition technique finds them. Here the focus is on how they are stored.
A condition record has these parts:
- A condition type, such as
PR00for the base price,K007for a customer discount orMWSTfor tax. - A key made of the fields in a condition table, such as customer and material, or price list and material.
- A validity period, with a start and end date.
- A rate and currency or percentage, optionally with scales (for example a lower price above 100 units).
The header is stored in KONH, and the rate and scale data in KONP and KONM. The key fields sit in a condition table with a name like A305, whose rows point to the header through the condition record number KNUMH.
You create and change conditions with VK11, VK12 and VK13, or with Fiori apps such as Manage Prices. Prices that apply to more specific keys are usually found first, because the access sequence tries the most specific key first.
SELECT h~knumh, h~kschl, h~datab, h~datbi,
p~kopos, p~kbetr, p~konwa, p~kpein, p~kmein
FROM konh AS h
INNER JOIN konp AS p ON p~knumh = h~knumh
WHERE h~kappl = 'V'
AND h~kschl = 'PR00'
AND h~datab <= @sy-datum
AND h~datbi >= @sy-datum
INTO TABLE @DATA(lt_prices).KAPPL = 'V' is the application for sales and distribution. KBETR holds the rate, KPEIN the pricing unit, so a rate of 10.00 per 1 piece and 10.00 per 100 pieces differ by a factor of 100. Read KBETR together with KPEIN and KMEIN.
Common errors
| Symptom | Likely cause |
|---|---|
| Customer not defined for sales area | Missing `KNVV` row, or missing customer role on the BP |
| Material not found in sales area | Missing `MVKE` row for that sales org and distribution channel |
| No price found | No valid condition record, wrong customer pricing procedure, or expired validity |
| Wrong payer or ship-to proposed | Partner functions in the customer master are wrong |
| Wrong account on goods issue | Wrong valuation class in the accounting view |
Exercise
A sales order for customer 1000 in sales organization 1010 reports "No price found" for material FG-100, although a PR00 record exists for that material. Name three master data checks you would make.
Show answer
First, check the validity dates of the PR00 record against the pricing date of the order. Second, check that the key of the record matches the order, for example the customer, price list or distribution channel it was created for. Third, check the customer pricing procedure (KALKS in KNVV) and the material pricing group, because a wrong value can lead to a procedure or access that does not read the record.
Exercise
Which table holds the sales area data of a customer, and which table links a customer to its Business Partner in S/4HANA?
Show answer
KNVV holds the sales area data. CVICUSTLINK links the customer to its Business Partner through the partner GUID.