SAP - Working with number ranges in ABAP
Monday, December 31, 2007 | Labels: ABAP | 0 comments |Working with number ranges is a little tricky, so I thought that I should log this somewhere so that I don't have to 'study' it again in the future.
Creating number ranges is easy. You can do it via TCode OYSM.
In ABAP, you can do certain number range manipulations via usage of function modules. They are:
NUMBER_RANGE_INFO_GET_ALE
This is how you can get the information on the number range.
NUMBER_RANGE_ENQUEUE
Before you start asking for the next number in the number range, you should enqueue the number range first.Or you are going to end up with duplicates.
NUMBER_GET_NEXT
This is how you get the next number in the number range.
NUMBER_RANGE_DEQUEUE
This is how you dequeue your number range once you are done with everything.
WARNING:
Using the function module NUMBER_RANGE_INFO_GET_ALE will allow you to get the current number in the number range; but let's say that your current number is 10 (assuming your number range is 01 -> 99):
1. Get current using NUMBER_RANGE_INFO_GET_ALE (it will give you 10)
2. Get next number using NUMBER_GET_NEXT (you get 11, of course)
3. Get current using NUMBER_RANGE_INFO_GET_ALE (it will STILL give you 10)
This will happen even if you do a COMMIT or DEQUEUE on the number range. It sucks, but you should be able to come up with your own logic to overcome this.
These are the most used number range function modules. If you know of any others that you have used before that has proved useful to you, please let me know.
