Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Generate number range with date

Former Member
0 Likes
2,813

We would like to generate a unique numeric value to represent an external invoice number. This number begins with the current date followed by the next number in the sequence 0-9999 e.g. 201109070001. The sequence needs to be reset to 1 at the start of each day.

We currently use a program to select and update a database table which stores the date and next number in the sequence for a given day and finally reset the number at the start of each day. Unfortunately we sometime experience duplications of the invoice numbers.

I've tried using a SAP number range object (transaction SNRO) but I can't find a function to reset the number.

Is there a function to reset a SAP number range object or an alternate method to obtain the required results?

Thanks,

Nicholas

1 ACCEPTED SOLUTION
Read only

former_member209703
Active Contributor
0 Likes
1,727

RRBA_NUMBER_RANGE_RESET

7 REPLIES 7
Read only

former_member209703
Active Contributor
0 Likes
1,728

RRBA_NUMBER_RANGE_RESET

Read only

Former Member
0 Likes
1,727

Hi,

It is not recommended to reset the number range. Why cant you try finding a function module where you can propose a number based on the requirement.

Please check the below thread :

Shiva

Read only

Former Member
0 Likes
1,727

At first, sorry if i sound any harsh or what, thats in no way intended. I´m just a technician.

What i dont get is, why you dont just do that yourself. either create a table or make use of a TVARVC variable where you store your last number, along with the date where it was created/used.

you can easily write a FM which does what NUMBER_GET_NEXT does. Means if a number is requested, goto your table or TVARVC variables (yeah two, one for number, one for the date), and check what number you got there.

If date = sy-datum then increment number by one, store it to your table/TVARVC variable, and return that number as an exporting parameter.

elseif date # sy-datum then store 1 and your new date in your table/TVARVC variables and return it as exporting parameter.

As it would be a FM of your own, soleley for this purpose you can even return a concatenated value of sy-datum and your number, instead of just the number.

I would estimate a maximum workload of one hour for such a solution, and it would exactly do what you need.

hope you got my drift.

Read only

Former Member
0 Likes
1,727

Florian, your suggestion is what we currently have in place and for the most part it is works. However, every once an a while we find orders with the same invoice number. This number is suppose to be unique for each external invoice.

I'm trying to eliminate all chances of duplicated invoice numbers and using a number range object seems to be my best bet.

Read only

0 Likes
1,727

Are you locking your number range table while you get the next number and update it?

Rob

Read only

Former Member
0 Likes
1,727

The table isn't locked. How do I go about locking?

Please note it is frequently accessed.

Read only

0 Likes
1,727

Locking tables is pretty basic. Please search the forums for ideas.

Rob