Sub topic 6
Groupings and number ranges
This chapter explains how a business partner grouping decides which number range a new partner draws from, and how that choice carries over to customer and supplier numbers. It assumes you know what a business partner category and role are, and that you are familiar with the ABAP Dictionary and with SAP number range objects.
What a grouping is
A grouping is a key that you pick when you create a business partner. It does two jobs:
- It points to one number range. The partner's number comes from that range.
- It acts as a classification you can report on, for example "domestic customers", "one-time accounts", or "employees".
Category and role describe what the partner is and what it does. The grouping describes how the partner is numbered and classified. The three are independent. You can create a person and an organization with the same grouping, as long as the number range allows it.
The grouping is stored in the field BU_GROUP of table BUT000, and the API exposes it as BusinessPartnerGrouping. Each system defines its own groupings in customizing. Codes such as BP02 in examples are only illustrations. Read the real values from your system before you use them.
Internal and external number assignment
Each number range is flagged as internal or external, and the grouping inherits that behavior.
| Aspect | Internal assignment | External assignment |
|---|---|---|
| Who chooses the number | The system, from the next free number in the interval | The user or the interface, within the interval |
| Typical use | Interactive creation in transaction BP | Migration, and numbers that must match a legacy or external system |
| Number format | Numeric | Numeric or alphanumeric, depending on the interval |
| Main error | Interval exhausted | Number outside the interval, or already used |
A system usually has at least one grouping of each kind. Migrations and interfaces use the external ones, and daily maintenance uses the internal ones.
Number ranges for business partners belong to number range object BU_PARTNER. You normally reach it from the customizing activity for number ranges rather than by calling SNRO directly. An interval has a from-number, a to-number, and the external flag. Several groupings can point to the same interval, and a grouping points to exactly one.
How the number reaches the customer and the supplier
In S/4HANA the business partner is created first. Customer/Vendor Integration (CVI) then creates the customer and supplier records. The default is that the customer number and supplier number equal the business partner number. That choice gives every partner one number across sales, purchasing and finance.
CVI keeps two mappings, and both must be consistent with the grouping:
- Direction BP to customer and BP to supplier. For each grouping, a customer account group and a supplier account group are assigned. The account group decides field control and its own number range in the classic master.
- Direction customer to BP and supplier to BP. This is used when a record is created through a classic path. For each account group, a grouping is assigned.
The BP number must also fit the number range of the target account group. When the customer or supplier takes the BP number, the account group's range has to accept externally supplied numbers in that interval. If the BP range is internal, the partner gets a number first, and the account group range must be external and cover the same interval. If the two ranges do not overlap, synchronization fails even though the partner itself was saved.
The number range objects of the classic masters are DEBITOR for customers and KREDITOR for suppliers. Their intervals are maintained per account group in the classic number range transactions, which customizing still offers.
Design rules that prevent most problems
- Define one interval per business purpose. Keep customers, suppliers, one-time accounts and employees apart, so a number tells you something at a glance.
- Make the BP interval and the account group intervals identical. If the numbers differ, the "same number" idea breaks, and every cross-reference between systems needs a translation table.
- Reserve an external interval for migration. Load legacy numbers there and leave internal intervals for new partners.
- Choose alphanumeric ranges only when every target needs them. The BP can hold alphanumeric external numbers, but the account group range on the customer or supplier side must accept them too.
- Plan for growth. Intervals are easy to enlarge but hard to merge, because numbers may already be in use.
Checking what your system uses
To see which groupings are actually in use, count partners per grouping. This report is complete and runs in a system with ABAP access:
REPORT z_bp_grouping_usage.
SELECT bu_group, COUNT(*) AS partner_count
FROM but000
GROUP BY bu_group
ORDER BY bu_group
INTO TABLE @DATA(lt_usage).
cl_demo_output=>display( lt_usage ).A grouping with zero rows may be unused, or may have been defined only for a future project. A grouping with a large count and an external interval that is nearly full needs attention soon.
You can read the same field through the released OData service. This request returns the grouping together with the customer and supplier keys that CVI assigned:
GET /sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner?$select=BusinessPartner,BusinessPartnerGrouping,Customer,Supplier&$top=5
Accept: application/jsonWhen the "same number" approach is in force, BusinessPartner, Customer and Supplier hold the same value for a partner that has both roles. If they differ, either the mapping uses different ranges or the records were created before CVI was set up.
Creating a partner with a grouping through the API
When you create a partner through the API, you send the grouping in the request body. With an internal grouping, you omit BusinessPartner and the system assigns the number. With an external grouping, you must send BusinessPartner yourself, inside the interval. A request with an external grouping and no number is rejected, and so is an internal grouping with a number.
POST /sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner
Content-Type: application/json
x-csrf-token: <token fetched with a prior GET using x-csrf-token: fetch>
{
"BusinessPartner": "9000001234",
"BusinessPartnerCategory": "2",
"BusinessPartnerGrouping": "BP02",
"OrganizationBPName1": "Example Trading GmbH",
"to_BusinessPartnerRole": [
{ "BusinessPartnerRole": "FLCU00" }
]
}Here BP02 is assumed to be an external grouping and 9000001234 a free number in its interval. In your system, use a grouping that is external, and a number that is inside its interval and not yet taken. Remove the BusinessPartner line to use an internal grouping.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| "Number is not in the interval" on save | External number outside the interval of the grouping | Use a number inside the interval, or extend the interval |
| "Number range is exhausted" | Internal interval full | Enlarge the interval, or switch to a new interval and grouping |
| Partner saved, no customer or supplier created | The grouping has no account group mapping, or the account group range rejects the number | Complete the CVI mapping and align the intervals |
| "Number already exists" | The number is used by another partner or by a classic record outside CVI | Check `BUT000` and the classic tables for the number, and pick another |
| Alphanumeric number accepted in BP but not in the customer | Customer account group range is numeric only | Make the ranges compatible, or restrict the BP interval to numeric values |
The last two errors are the most frequent after migrations. They happen when legacy customers and suppliers share numbers, because a customer 1000 and a supplier 1000 can no longer both exist under the "same number" rule unless they are the same partner.
Exercise
A new grouping uses an internal BP interval from 1000000000 to 1999999999. After the first partner is saved, CVI does not create a customer. The customer account group mapped to this grouping has an internal range. What is wrong, and what do you change?
Show answer
The partner number is generated by the BP range, and CVI tries to give that number to the customer. An internal account group range generates its own numbers and cannot accept the number supplied by the BP. Change the account group range to external, with an interval that covers 1000000000 to 1999999999, so that the BP number can be used as the customer number.
Exercise
You create a partner through APIBUSINESSPARTNER with a grouping that is configured for external numbers, and you leave out the BusinessPartner field. What happens, and how do you fix the request?
Show answer
The request is rejected, because an external grouping requires the caller to supply the number. Add the BusinessPartner field with a free number inside the interval of that grouping, or use a grouping with internal number assignment so the system assigns the number.