SAP SNRO 防止跳号
前言
- 内存缓冲:跳号,无法被记录
- 并行缓冲:跳号概率很低,即使跳号可以被记录
方案一
-
配置 缓冲方式 为 无缓冲(
No buffering
) -
注意事项:
方案二
- 程序代码中 加锁,和 方案一 异曲同工
*&--- 进入队列
CALL FUNCTION 'NUMBER_RANGE_ENQUEUE'
EXPORTING
object = '<obj>'
EXCEPTIONS
foreign_lock = 1
object_not_found = 2
system_failure = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno DISPLAY LIKE sy-msgty
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*&--- 获取 SNRO 流水号
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01'
object = '<obj>'
ignore_buffer = 'X' " 设置为 'X',无视配置的缓冲选项
IMPORTING
number = no
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 = '<obj>'
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno DISPLAY LIKE sy-msgty
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Notes
Note 504875