Number Range Object-2

lightDetails of Number Range Object Creation, Interval Creation, Buffering, Warning



In the first post Number Range Object  we get to know what is number range in SAP & number range object.  In this post will create a number range object and its intervals and use this in application program to generate next number and other features.

To create a new number range object, go to the Tx- SNRO


Provide number range object name as – ZVECH_NUM and select Create button.


Provide the short text and long text.

For the field – Number Length Domain – It accepts only either NUM or CHAR type. Either you can enter data element or basic type. Here it is provided as NUM10 indicating that the number generated in a Numeric type with max length as 10.

% Warning – you can maintain a percentage here, so that the system would send a code when you reach that last percentage.

If the interval is from 1 to 100, then when the number range number generation reach at 90, the system send an appropriate code to the application program which can notify the user that the number range interval is about to be exhausted.


In the customizing tab, you can maintain the Buffering details.


Nothing to maintain here in our demo . Finally select Save.


So upto now a number range object is created with its features like its length, warning %, buffering etc. Now we have to create intervals.


Select Ranges button.


Select Edit Intervals button.


The below screen appears.


Provide a number range interval number as ’01’ and its range from  1 to 100. To create a new interval, select + button.


Provide interval no as ’02’ and its range from 101 to 200. Finally select Save button.


So upto now, we have created Number range object and its two intervals numbers 01 & 02.


The next part is how to use this in the application program. The FM – NUMBER_GET_NEXT’ can be  used to generated the next number.

The Fm accepts the Number range Object name and the interval number, to generate the next sequential number


Execute and here the first number is generated.


Execute again and here is the next number.


Now if you go to the Tx- SNRO and open the number range object ranges, for the interval ’01’ , the NR status is 10, but actually we generated the last number as ‘0000000002’. This is because of the buffering settings.


The buffer says 10 numbers are places in the buffer area.


To see the number range object details in the buffer area, execute Tx- SM56


From menu  select, Goto->Entries


Provide the client and the number range object name and continue.


Below are the details. we use the interval number as ’01’ and the current generate number is ‘2’ under column ‘STATUS’, the critical number is ’90’, as we have choose warning as 10%. So when it reaches 90 system sends outs a code to the application program by the FM- NUMBER_GET_NEXT. 


The number range generation by the FM, doesn’t always generates the next number always by a +1. This is controlled by the parameter QUANTITY.


If you don’t pass any value to it, it considers that the next number  to be generated is +1  of the last generated number.


We execute the program 3 times and we get the numbers as 7, next 8 and then 9.


If we need a next number that is always a +10 of the previous number, then we can pass QUANTITY as 10.


So the next numbers are generated as 20 , 30 & 40.


So we reached the next number as 93 for the interval 01 .


For interval ’02’ we have reached 103.


The SNRO details of the ranges.


The SM56 details of the number range buffer.


With the current buffer status, for the interval 01 the critical number range is 90 as we have specified warning % as 10. Now we have reached the number 95 means we are in the critical stage, then how to raise an warning message to the user.


The return code usually provide a code that corresponds to the critical stage or the last number of the number range.

Return code- 1  means we are in the critical stage according to the warning %.

Return Code- 2  means that is the last number of the number range interval.

The below program with a little change.


We handle the code in the program and generate a warning/info message to the user.



Tx- SM56 details of the number range buffer., We already generated number 99, now the interval 01 end at 100.


If we execute the program again to generate the last number, then the system send out a return code as 2 and the program shows a proper message to the user.


Tx- SM56 details about number range object buffers.


If we execute the program again, then the number range interval starts generating the number again from the start.


Tx- SM56 details.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s