Generate number for an object using NUMBER_GET_NEXT

 Generate number for an object using NUMBER_GET_NEXT

The  requirement was to generate a unique internal number for vendor address.

This is a function module to generate a  unique internal number in SAP system .
First of all FM NUMBER_RANGE_ENQUEUE
will lock the number range generator and then  
FM NUMBER_GET_NEXT will get the next available number 
FM NUMBER_RANGE_DEQUEUE will unlock the FM



CALL FUNCTION 'NUMBER_RANGE_ENQUEUE    EXPORTING

      object           = 'ADRNR' "Address number 
    EXCEPTIONS
      foreign_lock     = 1
      object_not_found = 2
      system_failure   = 3
      OTHERS           = 4.
  IF sy-subrc <> 0.
  ENDIF.

  IF p_chg NE 'X'.
    CALL FUNCTION 'NUMBER_GET_NEXT'
      EXPORTING
        nr_range_nr             = '01'
        object                  = 'ADRNR'
      IMPORTING
        number                  = p_l_f_address "ssytem generted 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.
    IF sy-subrc <> 0.

    ENDIF.
  ELSE.

  ENDIF.

*Dequeue the FM for address number
  CALL FUNCTION 'NUMBER_RANGE_DEQUEUE'
    EXPORTING
      object           = 'ADRNR'
    EXCEPTIONS
      object_not_found = 1
      OTHERS           = 2.
  IF sy-subrc <> 0.

  ENDIF.



No comments:

Post a Comment

/*Newer Post*/ Older Post Home