# NUMBER_GET_NEXT — Get Next Number from Number Range

> Assigns the next free number from an internal number range interval of a number range object (maintained in SNRO/SNUM). Custom programs and custom tables use it to create unique document or record numbers. Pass the object, interval (NR_RANGE_NR) and, if the object uses them, sub-object and fiscal year; check RETURNCODE, because a value other than space signals that the interval is close to or at its limit.

- Modules: CA
- Type: Function module
- Function group: SNR3
- Remote-enabled (RFC): No
- S/4HANA status: Used the same way in S/4HANA
- URL: https://nekuhub.com/en/functions/number-get-next/

## Importing parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| NR_RANGE_NR | INRI-NRRANGENR | Number range interval | Yes |
| OBJECT | INRI-OBJECT | Number range object | Yes |
| QUANTITY | INRI-QUANTITY | Number of numbers requested | - |
| SUBOBJECT | - | Sub-object value | - |
| TOYEAR | INRI-TOYEAR | Fiscal year | - |
| IGNORE_BUFFER | - | Ignore number range buffering | - |

## Exporting parameters

| Parameter | Type | Description |
|---|---|---|
| NUMBER | - | Next free number |
| QUANTITY | INRI-QUANTITY | Number of numbers assigned |
| RETURNCODE | INRI-RETURNCODE | Return code |

## Exceptions

- INTERVAL_NOT_FOUND: Interval not found
- NUMBER_RANGE_NOT_INTERN: Number range is not internal
- OBJECT_NOT_FOUND: Number range object not defined
- QUANTITY_IS_0: Requested quantity must be greater than 0
- QUANTITY_IS_NOT_1: Requested quantity must be 1
- INTERVAL_OVERFLOW: Interval used up
- BUFFER_OVERFLOW: Buffer is full

## Call template (ABAP)

```abap
CALL FUNCTION 'NUMBER_GET_NEXT'
  EXPORTING
    nr_range_nr = lv_nr_range_nr
    object = lv_object
  IMPORTING
    number = lv_number
    quantity = lv_quantity
    returncode = lv_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.
```

## Related tables

NRIV

