10-22-2008 5:20 AM
Hi,
I have created a Z-Table to store Request Details. User provides the details of the request.
when ever user saves the Request i will generate the Request Number.
My Constraint is these Request Numbers must be in serial.
I don't want to hit the database every time to know what the Latest Request Number is? Because these requests would be in thousands. Please suggest me the better way.
Thanks,
Sekhar.J
10-22-2008 5:30 AM
u can do this by using Number Range...
Maintain number range and intervals in transaction code SNUM
Coding...
call function 'NUMBER_RANGE_ENQUEUE'
exporting
object = 'ZOWNNO' "Create with SNUM
exceptions
foreign_lock = 1
object_not_found = 2
system_failure = 3
others = 4.
if sy-subrc ne 0.
* message e086 with 'Lock error' sy-subrc.
endif.
call function 'NUMBER_GET_NEXT'
exporting
nr_range_nr = wnorange
object = 'ZOWNNO'
subobject = wsubobj
importing
number = wdocno "Number generated by SAP
exceptions
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
internal_overflow = 6
others = 7.
if sy-subrc ne 0.
* message e086 with 'Number Range' sy-subrc.
endif.
call function 'NUMBER_RANGE_DEQUEUE'
exporting
object = 'ZOWNNO'.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
10-22-2008 5:23 AM
Hi,
There is no way to achieve this without accessing the database.
Though you can use the TIMESTAMP (DATE + TIME) to get a unique no. Though this wont be a continous but would be a unique number. You can also use the no of seconds concept(no of seconds passed since 1/1/1900) as is used in UNIX.
Regards,
Nirmal
10-22-2008 5:29 AM
yes..TIMESTAMP (date n time) is the only way u generate a serial without hitting DB..
but what if two requests created at the exact same time???
Edited by: soumya prakash mishra on Oct 22, 2008 6:29 AM
10-22-2008 5:30 AM
u can do this by using Number Range...
Maintain number range and intervals in transaction code SNUM
Coding...
call function 'NUMBER_RANGE_ENQUEUE'
exporting
object = 'ZOWNNO' "Create with SNUM
exceptions
foreign_lock = 1
object_not_found = 2
system_failure = 3
others = 4.
if sy-subrc ne 0.
* message e086 with 'Lock error' sy-subrc.
endif.
call function 'NUMBER_GET_NEXT'
exporting
nr_range_nr = wnorange
object = 'ZOWNNO'
subobject = wsubobj
importing
number = wdocno "Number generated by SAP
exceptions
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
internal_overflow = 6
others = 7.
if sy-subrc ne 0.
* message e086 with 'Number Range' sy-subrc.
endif.
call function 'NUMBER_RANGE_DEQUEUE'
exporting
object = 'ZOWNNO'.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
10-22-2008 6:19 AM