BASIS / FIELD NOTES

When an SAP Number Skips, Was a Document Deleted?

With main-memory buffering, a skipped number may never have been a document. A fictional example separates in-memory draws, package refills, restarts, multiple servers, and rollbacks.

When document 1002 is followed by 1011, and 1003 through 1010 are missing, the documents in between look deleted. If the number range uses main-memory buffering, those numbers may never have been given to a committed document. A skip is a clue about how numbers were handed out, not a deletion record.

The numbers in the 1000s are a fictional walk-through of that behavior. They were not queried or produced on a company system. Buffering and screen names can differ by product and release. Parallel buffering returns a number after rollback, so it is not the loss described below.

When memory already has numbers, and when it does not

A number range buffer exists so frequent assignment does not wait on the database every time. If main memory still has numbers, the request takes one from the buffer and does not read NRIV. Without a buffer, the next user waits on the same number line until the first user commits.

Taking a number that is already in memory and refilling an empty package from NRIV are not the same step. After an instance has just started, or after the previous package is used up, the request loads a new package from NRIV, as large as the reserved buffer. The numbers used for that interval increase by the same amount. Most number range objects delivered as standard use this main-memory method, but the object behind the document in front of you still has to be checked in SNRO or SNUM. The reserved quantity differs by object. For frequent assignment, 10 to 1,000 is common.

This sequence applies when one number is assigned with NUMBER_GET_NEXT, the buffer is not ignored, and main-memory buffering is on. If an application bypasses the buffer, the sequence can differ.

Illustrative diagram for buffer size 10. While memory still has numbers, the request takes one from the buffer and does not read NRIV. When the package is missing or empty, a new package 1001 through 1010 is loaded from NRIV and the numbers used increase by 10. After that, numbers through 1010 come from memory, and NRIV is read again only when they run out.
A request does not read NRIV while memory still has numbers. Only an empty package loads ten numbers from NRIV, and the numbers used increase by the same amount.

A new package skips numbers before they become documents

The example assumes internal assignment, a buffer size of 10, a last used number of 1000, and a next number of 1001. The first request, with no package in memory, loads 1001 through 1010 and increases the numbers used by 10. Later requests take numbers from memory until that package is used up.

When the package is filled, the numbers are written to the database before they are handed to the work process that asked for them. If the server goes down, numbers still in memory can disappear as a group, and a gap can be on the order of the buffer size for each active server. If only 1001 and 1002 are committed and the instance then restarts, 1003 through 1010 are lost from the supply. They were not deleted documents. They were never assigned to a committed document.

Illustrative diagram of an instance restart after only 1001 and 1002 are committed documents. Numbers 1003 through 1010 existed only in memory and are lost from the supply. That loss is not evidence of deleted documents.
If the instance restarts after only 1001 and 1002 are committed, 1003 through 1010 disappear without becoming documents.

“There is no document 1003” does not by itself prove deletion or archiving. If no committed document has that number, and the server restarted after the interval had been loaded, the gap can come from the buffer. The buffer is still not the cause of every missing number. Another interval, another year, or another number range object can also explain it.

With two servers, a higher number can appear first

When several instances are running, each one keeps its own buffer for the interval. The number comes from whichever instance runs the program, and the numbers cannot be sorted chronologically.

Continue the example. A has loaded 1001 through 1010 and committed only 1001 and 1002. When B requests a number, it loads the next package, 1011 through 1020, into its own memory. Once B commits 1011, a list can show 1001, 1002, and 1011, with 1003 through 1010 absent. The number alone does not say whether 1011 was created later than 1003. Number 1003 might still be in A's memory, or it might already have been lost when A restarted. Creation order belongs to a value that records time, such as the document entry time. The size of the number says more about which server's package it came from.

Illustrative diagram of separate buffers on instances A and B. A's package is 1001 through 1010, with 1001 and 1002 committed. B's package is 1011 through 1020, with 1011 committed. A list may show 1001, 1002, and 1011 while 1003 through 1010 are absent. Number size is not creation time.
While A holds 1001 through 1010, B can commit 1011. The presence of 1011 does not mean document 1003 was deleted.

Whether a rolled-back number returns depends on the buffer size

A number already taken from the main-memory buffer is not returned on rollback, so document numbers can gap. If the numbers must not gap, or the law does not allow gaps, leave this buffer off. When the buffer holds more than one number, a commit leaves the package in memory. That commit does not turn the whole package into documents, and a rollback loses the numbers. With buffer size 1, ascending order is kept, but a rollback still loses that number, so the sequence is chronological but not necessarily complete. Buffer size 0 means no buffering: a rollback keeps the number available.

A large buffer discards more numbers when an instance restarts. Whether buffering is on matters more than the exact size. This article does not pick a size. Parallel buffering keeps packages in NRIVSHADOW and returns a number after rollback or restart. It also cannot be gap-free, chronological, and buffered at the same time.

Illustrative comparison of main-memory buffering only. Buffer size 0 keeps a rolled-back number available. Buffer size 1 keeps ascending order but loses the number on rollback. A buffer larger than 1 still holds the package in memory after commit, and rollback loses the numbers instead of returning them. Parallel buffering is not in this table.
With main-memory buffering, buffer size 0 keeps a rolled-back number available. Size 1 or more loses it.

Questions to write down before treating a gap as a deletion

A missing number is not a reason to restore a document or to clear the buffer. Transaction SM56 shows what the current server still holds: client, number range object, subobject, interval, year, whether the interval is external, the current number, and the last number the buffer can assign. It is not a history of numbers already lost in a restart. Changing or deleting an interval clears the buffer, and a global clear removes entries on every server. Clearing the buffer to close a gap can discard numbers that have not been used yet.

  • Which object and interval produced this number? Do not infer the object from the number of digits.
  • In SNRO or SNUM, is main-memory buffering on, and what quantity is reserved?
  • Is there really no committed document for the missing number, or has another year or interval been mixed in?
  • If there is more than one server, are you reading number size as creation order?
  • Could a restart or a rollback have occurred? If there is no committed document, suspect that the number was never assigned before you suspect deletion.

When a document must not have gaps, review leaving the buffer off before changing anything else. Whether to change the setting is a decision for someone who knows the application and the legal requirement. This example is not an instruction to change a live setting. A skipped number is not evidence that a document was deleted. First distinguish which server's package received the number, and whether a restart or a rollback discarded it before a document was committed.

END OF NOTEBack to the library
COMMENTS BOX

Add your perspective.

Share a question, another approach, or something you have tried.

Newest first

Checking sign-in…

Loading comments…