02-23-2010 11:50 AM
I am maintaining a number sequence in the ztable ie 4 digitis ie from
0001 to 9999 along with time and date.
And i am using the select single max query to get the next number and after getting then updating that number in the end of the program.
we wont maintain the numbers in sequence, user will maintain by table maintainance, it depends on user. where ever there is a blank that number we need to use.
For example
0001
0002
0003
0005
0020
9999
in the above case after reaching 9999 it need to go to 0004 and after that goto 0006 etc.
please tell how to do
02-23-2010 11:56 AM
Hi,
Ask the user to maintain another field type Char1 which means status (Available/or NOT).
select Min of available value from that table maintained. This is the simplest way.
Programatically is very difficult and may not be consistent." for that one should know the entire table structure Etc
" to give you some insight.
And once the Next number is used update the Available Flag field with X( or any thing suitable to you )
Hope this serves your purpose.
Cheerz
Ram
02-23-2010 12:02 PM
HI,
1. Check if number is 9999.
2. If yes then update new internal table having only one field COUNT(4) with number from 0001 to 9999.
loop
incriment the count
append tab_new.
endloop.
3. Tab_new has 9999 entries.
4. Sort your table ( let say tab1) ascending by counter.
5. loop at tab_new.
6 Read table tab1 with key counter = tab_new-counter.
7. If sy-subrc fails then tab_new-counter has the nuber you need.
Little odd logic but I believe it will work
02-23-2010 1:17 PM
data: lf_index(04) type n.
lf_index = 1.
do.
select single * from ztable
where sequence = lf_index.
if sy-subrc ne 0.
exit.
endif.
add 1 to lf_index.
if lf_index = 9999.
exit.
endif.
enddo.
Atthe end of the DO-ENDDO ,field lf_index will contain the number to use
(or 9999 if all numbers are already taken).
Bye.
02-24-2010 8:49 PM
Why dont you generate the next number in table maintenance without allowing the user to enter it.
Is it the requirement that user should maintain the numbers ?
02-26-2010 12:52 PM
02-26-2010 1:00 PM
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01' "Number range of your number circle
object = 'NAME' "of your created number circle
IMPORTING
number = name "of your datafield in which the next number should be inserted
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
buffer_overflow = 7
OTHERS = 8.
Hope this helps
02-26-2010 1:58 PM
This is the code
tables : zsequense.
data : maxnum(4) type n.
data : prevnum(4) type n, diff type i, reqnum(4) type n.
data : i_zsequense like zsequense occurs 0 with header line.
select max( znum ) from zsequense into maxnum..
if maxnum = '9999'.
select * from zsequense into table i_zsequense.
sort i_zsequense.
loop at i_zsequense.
if sy-tabix = 1.
prevnum = i_zsequense-znum.
endif.
if sy-tabix ne 1.
diff = i_zsequense-znum - prevnum.
if diff > 1.
reqnum = prevnum + 1.
exit.
endif.
endif.
prevnum = i_zsequense-znum.
endloop.
endif.
write / reqnum.
02-27-2010 9:53 AM
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01'
object = OBJECT NAME
subobject = '000001'
toyear = '9999'
IMPORTING
number = number
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
buffer_overflow = 7
OTHERS = 8.