‎2007 Aug 08 6:03 AM
hi all,
can u tell me about this function module NUMBER_GET_NEXT?
How it will work ? What we have to pass?
thanks
srinivas
‎2007 Aug 08 6:06 AM
Create a serial number range object in SNRO transaction(give 01 in starting number) and every time you want a new number you can call the NUMBER_GET_NEXT function.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01' (or pass the Variable)
object = 'ObjectName'
IMPORTING
number = number.
http://www.erpgenie.com/sap/abap/code/abap33.htm ex---- General - Number Range Generation * In the 4.6x environment, SAP have included a number range generation * program just like those used for Purchase Order, Sales Order etc. * * This SAP number range generation is an include program. * * [code]INCLUDE ZRANGENO.
*
Always have to be included in the main program data declaration
*
data: wnorange like INRI-NRRANGENR, "number range,
wsubobj like inri-SUBOBJECT, "sub object
wdocno(12).
*
Steps :-
1. Number range Sub Object must be maintain in table ZSGRP
You can used transaction SE16 to create a table entries.
2. Maintain number range and intervals in transaction code SNUM
*
Written by : SAP Basis, ABAP Programming and Other IMG Stuff
*
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
‎2007 Aug 08 6:06 AM
Create a serial number range object in SNRO transaction(give 01 in starting number) and every time you want a new number you can call the NUMBER_GET_NEXT function.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01' (or pass the Variable)
object = 'ObjectName'
IMPORTING
number = number.
http://www.erpgenie.com/sap/abap/code/abap33.htm ex---- General - Number Range Generation * In the 4.6x environment, SAP have included a number range generation * program just like those used for Purchase Order, Sales Order etc. * * This SAP number range generation is an include program. * * [code]INCLUDE ZRANGENO.
*
Always have to be included in the main program data declaration
*
data: wnorange like INRI-NRRANGENR, "number range,
wsubobj like inri-SUBOBJECT, "sub object
wdocno(12).
*
Steps :-
1. Number range Sub Object must be maintain in table ZSGRP
You can used transaction SE16 to create a table entries.
2. Maintain number range and intervals in transaction code SNUM
*
Written by : SAP Basis, ABAP Programming and Other IMG Stuff
*
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
‎2007 Aug 08 6:07 AM
Hi Srinivas,
Used to get the next unique number in a number range. Use tcode SNRO for maintaining number ranges.
Create a serial number range object in SNRO transaction(give 01 in starting number) and every time you want a new number you can call the NUMBER_GET_NEXT function.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01' (or pass the Variable)
object = 'ObjectName'
IMPORTING
number = number.
hope this helps.
‎2007 Aug 08 6:07 AM
Hi,
Check below the Fm documentation.
If you have access to the system then open this FM in SE37 and click Function module documentation else here is the documentation.
NUMBER_GET_NEXT
____________________________________________________
Short Text
NUmber range: Assigns next free number
Preliminary comment
This function module has been released.
The documentation is being revised so that it conforms to the requirements for released function modules.
The function module assigns the next free numbers of a number range. A number is assigned as a default if no larger number is demanded in the parameter QUANTITY. If more than one number is demanded and not enough numbers are available up to the interval limit, the numbers are only assigned up to the interval limit. If the last number was assigned, the first interval number is provided again during the next call.
The length of the number depends on the definition of the number range object. However, the length is not determined from the definition when allocating, but is calculated from the length of th from-number of the number range.
All exceptions are created with MESSAGE ... RAISING ... .
Example:
1. Object HUGO, not year-dependent, next free number searched for
DATA: RC LIKE INRI-RETURNCODE,
NUMBER(10) TYPE C.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING OBJECT = 'HUGO'
NR_RANGE_NR = '01'
IMPORTING RETURNCODE = RC
NUMBER = NUMBER.
CASE RC.
WHEN ' '.
everything o.k.
WHEN '1'.
the assigned number lies in the critical area.
WHEN '2'.
this was the last number, next time the first number
will be assigned
ENDCASE.
2. Object EGON, year-dependent, next 5 free numbers for 1992 in company code 0001 searched for.
DATA: RC LIKE INRI-RETURNCODE,
NUMBER(10) TYPE C,
YEAR LIKE INRI-TOYEAR,
QUAN LIKE INRI-QUANTITY.
YEAR = '1992'.
QUAN = 5.
T001-BUKRS = '0001'.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING OBJECT = 'EGON'
NR_RANGE_NR = '01'
SUBOBJECT = T001-BUKRS
TOYEAR = YEAR
IMPORTING RETURNCODE = RC
QUANTITY = QUAN
NUMBER = NUMBER.
the last assigned number is in NUMBER
the number of the assigned numbers is in QUANTITY
the first free number is calculated from:
NUMBER - QUANTITY + 1.
CASE RC.
WHEN ' '.
everything o.k.
WHEN '1'.
the assigned number lies in the critical area.
WHEN '2'.
this was the last number, next time the first number will be assigned
*
WHEN '3'.
more numbers are demanded than are available,
the number of the assigned numbers is in QUAN.
ENDCASE.
Regards,
Sesh
‎2007 Aug 08 6:08 AM
Hi,
The function module assigns the next free numbers of a number range. A number is assigned as a default if no larger number is demanded in the parameter QUANTITY. If more than one number is demanded and not enough numbers are available up to the interval limit, the numbers are only assigned up to the interval limit. If the last number was assigned, the first interval number is provided again during the next call.
The length of the number depends on the definition of the number range object. However, the length is not determined from the definition when allocating, but is calculated from the length of th from-number of the number range.
All exceptions are created with MESSAGE ... RAISING ... .
Example:
1. Object HUGO, not year-dependent, next free number searched for
DATA: RC LIKE INRI-RETURNCODE,
NUMBER(10) TYPE C.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING OBJECT = 'HUGO'
NR_RANGE_NR = '01'
IMPORTING RETURNCODE = RC
NUMBER = NUMBER.
CASE RC.
WHEN ' '.
everything o.k.
WHEN '1'.
the assigned number lies in the critical area.
WHEN '2'.
this was the last number, next time the first number
will be assigned
ENDCASE.
2. Object EGON, year-dependent, next 5 free numbers for 1992 in company code 0001 searched for.
DATA: RC LIKE INRI-RETURNCODE,
NUMBER(10) TYPE C,
YEAR LIKE INRI-TOYEAR,
QUAN LIKE INRI-QUANTITY.
YEAR = '1992'.
QUAN = 5.
T001-BUKRS = '0001'.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING OBJECT = 'EGON'
NR_RANGE_NR = '01'
SUBOBJECT = T001-BUKRS
TOYEAR = YEAR
IMPORTING RETURNCODE = RC
QUANTITY = QUAN
NUMBER = NUMBER.
the last assigned number is in NUMBER
the number of the assigned numbers is in QUANTITY
the first free number is calculated from:
NUMBER - QUANTITY + 1.
CASE RC.
WHEN ' '.
everything o.k.
WHEN '1'.
the assigned number lies in the critical area.
WHEN '2'.
this was the last number, next time the first number will be assigned
*
WHEN '3'.
more numbers are demanded than are available,
the number of the assigned numbers is in QUAN.
ENDCASE.
<b>check FM documentation</b>
Regards,
Satyendra
‎2007 Aug 08 6:09 AM
Hi Srinivas,
It is used for number range to get the next number
Regards
Arun
‎2007 Aug 08 6:16 AM
Hi,
This fun module is used to generate continuous numbers for any document:
First you have to create an object in the SNRO Transaction, and that has to be passed to this fun module.
see the sample code:
&----
*& Form GET_NEXT_NUMBER
&----
FORM get_next_number_class.
DATA: inumber(10) TYPE c.
SELECT SINGLE * FROM klah WHERE class = 'PRODUCTCODE'.
IF sy-subrc NE 0.
entry in KLAH is not yet exiting => get next number
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01'
object = 'KLASSE'
quantity = '1'
SUBOBJECT = ' '
TOYEAR = '0000'
IGNORE_BUFFER = ' '
IMPORTING
number = inumber
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
BUFFER_OVERFLOW = 7
OTHERS = 8
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ELSE.
entry is already existing => take the number
inumber = klah-clint.
ENDIF.
ENDFORM. " GET_NEXT_NUMBER
Regards