在ABAP中使用自增ID
1.创建流水号对象
事务代码:SNRO
2.设置流水号对象自增的区间(号码段)
事务代码:SNRO
3.在代码中获取流水号
DATA iv_bankid TYPE char8. DATA iv_bankl TYPE bnka-bankl. CLEAR:iv_bankid,iv_bankl. DO 5 TIMES. CALL FUNCTION 'NUMBER_RANGE_ENQUEUE ' EXPORTING object = 'ZBANKID' EXCEPTIONS foreign_lock = 1 object_not_found = 2 system_failure = 3 OTHERS = 4. IF sy-subrc EQ 0. CALL FUNCTION 'NUMBER_GET_NEXT ' EXPORTING nr_range_nr = '1' object = 'ZBANKID' IMPORTING number = iv_bankid 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. CALL FUNCTION 'NUMBER_RANGE_DEQUEUE ' EXPORTING object = 'ZFLOGNO001' EXCEPTIONS object_not_found = 1 OTHERS = 2. ELSE. WAIT UP TO 1 SECONDS. ENDIF. ENDDO.