Skip to Content
1
Former Member
May 17, 2010 at 01:30 PM

Autoincrement via NUMBER_GET_NEXT

374 Views

Hello Guys,

i have a table where i like to fill the column ID automatically with kind of autoincrement.

Therefore i created a NumberRangeObject like described in http://www.kodyaz.com/articles/create-number-range-in-abap-using-sap-snro-transaction-code.aspx

And applied it in a testprogram as shown in the following:

REPORT  ZSS10_15_CREATEIDTEST.

DATA :
 lv_nextnum TYPE i,
 wnorange like INRI-NRRANGENR,            "number range,
 wsubobj  like inri-SUBOBJECT.            "sub object


call function 'NUMBER_GET_NEXT'
         exporting
               nr_range_nr         = wnorange
               object              = 'ZSS10_15_1'
               subobject           = wsubobj
         importing
               number                  = lv_nextnum  "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.


write lv_nextnum.

My problem now is, that it seems not to increment.

Everytime i execute this program, it writes out "0".

I would have expected an inc with every call: "0", "1", "2",...

What have i done wrong?

Best regards

Philipp