SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Generating a number range automatically



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Thu Dec 20, 2007 10:21 pm    Post subject: Generating a number range automatically Reply with quote

Generating a Number Range automatically
Developing class: SZN

If you need a unique key in a table or a sequential number for any other purpose, you can use a range object .
Ranges are maintained in transaction SNRO



After maintaining the first screen you have to maintain the intervals by clicking the button "number ranges"



This information is stored in tables :

- TNRO Definition of number range objects

- NRIV Number range intervals. Note: Field NRLEVEL Contains the last assigned number.

In your program you read the next number by using the function NUMBER_GET_NEXT

Code:
DATA l_number TYPE i.
CALL FUNCTION 'NUMBER_GET_NEXT'
    EXPORTING
        nr_range_nr = '01'
        object = 'ZTEST'
        quantity = '1'
    IMPORTING
        number = l_number
*       quantity = ' '
*       RETURNCODE =
    EXCEPTIONS
        interval_not_found = 1
        number_range_not_intern = 2
        object_not_found = 3
        quantity_is_0 = 4
        quantity_is_not_1 = 5
        interval_overflow = 6
        OTHERS = 7.

display l_number.

Each time you call NUMBER_GET_NEXT the number is automatically increased.

You can also create the number range in your program instead of using SNRO with the functions:

NUMBER_RANGE_INTERVAL_LIST : verify if a number range already exist
NUMBER_RANGE_ENQUEUE : lock the specifier number range
NUMBER_RANGE_INTERVAL_UPDATE : create the number range
NUMBER_RANGE_UPDATE_CLOSE : commit changes
NUMBER_RANGE_DEQUEUE : unlock
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.