Skip to Content
Product Information

SAP Number Range Shenanigans

The shenanigans of alphanumeric SAP Number Ranges are a surprise even to seasoned experts.

You’re likely well aquatinted with the mundane task of maintaining numeric number ranges for most business objects. The behavior is easily understood because the SAP system straightforwardly considers them as, well … numbers. Adding alpha characters to the mix is less common, and the resultant behavior is significantly less intuitive.

Let’s have a detailed look at the behavior of alpha characters in external number ranges, the published rules, and some technical details behind system behavior, perhaps with an eye towards breaking the strictest of rules once they’re understood.

As an example, I’ll use number ranges commonly configured for ERP Vendors that support SAP Retail Site Masters. The use case exposes interesting number range behaviors.

In SAP Retail, the Best Practice for Site Numbers is that the 4-character Site number, Site Business Partner number, Site ERP Customer number, and Site ERP Vendor number are all the same number. For this reason, 4-character number ranges are typically reserved for all those related objects for Site Masters. To that end, Site ERP Vendors may have external number ranges defined like this example:

Example%20number%20ranges%20for%20ERP%20Vendor.

Example number ranges for ERP Vendor.

While this number range configuration may be common, and necessary, it probably doesn’t have the exactly intended result! In the case of A to ZZZZ, the number range doesn’t satisfy the intention of reserving only 4-character numbers.

To illustrate the system behavior, let’s consider a real-world example: adding another external number range for 5-character numbers:

Z3%20number%20range%20can%u2019t%20be%20created.%20It%20overlaps.%20Why%3F

Z3 number range can’t be created. It overlaps. Why?

The Z3 number range VN000 to VN999 can’t be added because it overlaps.

To understand why, let’s begin with a quick look at the F1 help available when maintaining a number range.

SAP%20Help%20for%20%u201CFrom%20Number%u201D%20field%20when%20maintaining%20a%20number%20range.

SAP Help for “From Number” field when maintaining a number range.

The strict declared dependency is: “External intervals can only contain either letters or numbers, as sorting can differ between platforms (Code page).”

If we are to believe this admonition, then a number range such as VN000 to VN999 cannot be created simply because any mixture of letters and numbers is verboten, never mind any overlap error. Fortunately, the system is a bit more flexible than suggested by the Help screen.

But before breaking any rules, let’s understand how the system stores and evaluates number ranges that include letters.

Storing Numbers

Let’s use Vendor Number (LIFNR) to illustrate the example of storing numbers, with and without letters.

Data%20Element%20LIFNR%20is%20defined%20as%2010%20characters.

Data Element LIFNR is defined as 10 characters.

Numeric%20entries%2C%20such%20as%201000%2C%20are%20stored%20as%2010%20characters%2C%20with%20leading%20zeros%20%28this%20is%20the%20unconverted%20value%29.

Numeric entries, such as 1000, are stored as 10 characters, with leading zeros (this is the unconverted value).

Non-numeric%20entries%2C%20such%20as%20R120%2C%20are%20also%20stored%20as%2010%20characters%2C%20with%20trailing%20spaces.

Non-numeric entries, such as R120, are also stored as 10 characters, with trailing spaces.

The system evaluates number range entries while number ranges are being maintained, and it separately evaluates number-range-relevant numbers – in the context of defined number ranges – when entered in a transaction, such as the entry of a Business Partner number during creation of a Business Partner.

The evaluation of the number is a comparison. For example, is the Business Partner number entry greater than the From Number of the number range, and is the Business Partner number entry less than the To Number of the number range. For example:

Here%u2019s%20the%20code%20that%20compares.

Here’s the code that compares.

 

SAP ABAP Keyword Documentation explains that when the comparison type is one of the character-like data types, the content is compared from left to right. Based on the internal binary representation in the code page used, the first differing character from the left determines which operand is greater.

Data Element LIFNR, for example, is defined as 10 characters, and all 10 characters are evaluated, beginning from left to right, until a differing character is determined.

Unexpected Numbers

The number range A to ZZZZ is evaluated as “A “ (1 character and 9 trailing spaces) to “ZZZZ “ (4 characters and 6 trailing spaces).

The number range A to ZZZZ isn’t a 4-character number range after all; it won’t constrain entries to 4 characters!

Surprising Examples

Numbers are “smaller” than letters.

This is demonstrated as A to 1 results in an error:

This is also demonstrated as 1 to A is a valid range:

 

Only external ranges permit non-numeric characters.

This is demonstrated as A to ZZZZ for an internal number range results in an error:

 

Alpha ranges include numbers.

These number ranges are typically maintained for Sites.

Z1 permits numeric only Site Vendor numbers from 1 to 9999.
But consider example Range Z2: A to ZZZZ.

Because numbers are “smaller” than letters, Range Z2 (A to ZZZZ) achieves the following scenario:

  • Must begin with a letter (From Number is A, thus a number is not permitted as the first character).
  • Numbers are allowed following the first character (To Number is ZZZZ, and R123 is permitted because 123 is “smaller” than ZZZ).

To illustrate, let’s create a Vendor:

And Vendor number R123 is a permitted value:

Because numbers are “smaller” than letters, Range Z2 (A to ZZZZ) permits numbers following the first character.

Because numbers are “smaller” than letters, it is not possible to define a strictly alpha range that spans multiple characters (e.g. 2 or more alpha characters).

Alpha ranges include spaces.

If you have a number range like Range Z2 (A to ZZZZ), you can still create master data with a number such as R123456789.

 

If you have a number range like Range Z2 (A to ZZZZ), you probably did not mean to permit R123456789. But you did!

The reason for this is simply technical: This interval (A – ZZZZ) is understood by the system like this:
[A ] – [ZZZZ ]
(note the spaces after the characters).

SAP stores number ranges in ten characters and if you don’t use all ten characters, then SAP thinks there are spaces there (which is technically true) and unexpected things could happen.

00000P1000 – 00000P9999

or

P000001000 – P000009999

Reference

  • SAP Note 2664295 – Error while creation of Business Partner with External Number range.
  • SAP Note 2380479 – Unexpected error NR600 “Enter intervals without overlap” when creating an interval
  • SAP Note 1076122 – SNUM: Number ranges overlap – NR 600
Be the first to leave a comment
You must be Logged on to comment or reply to a post.