cancel
Showing results for 
Search instead for 
Did you mean: 

finding next number

Former Member
0 Kudos

hi gurus,

what is the Fm for auto generation of numbers & how to get the number range object for date.

thaks & regards,

santosh.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

FM : NUMBER_GET_NEXT

DATA l_number TYPE i.

CALL FUNCTION 'NUMBER_GET_NEXT'

EXPORTING

nr_range_nr = '01'

object = 'ZTEST'

quantity = '1'

IMPORTING

number = l_number

  • 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

OTHERS = 7.

display l_number.

each time you call NUMBER_GET_RANGE the number is automatically increased.

You can also create the number range in your program instead of using SNRO with the functions:

NUMBER_RANGE_INTERVAL_LIST : verify if a number range already exist

NUMBER_RANGE_ENQUEUE : lock the specifier number range

NUMBER_RANGE_INTERVAL_UPDATE : create the number range

NUMBER_RANGE_UPDATE_CLOSE : commit changes NUMBER_RANGE_DEQUEUE : unlock

Former Member
0 Kudos

Hi,

Use FM NUMBER_GET_NEXT

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,

Satish