SAP号码段配置-SNRO/SNUM
T-CODE: SNRO、SNUM
1.创建一个号码段对象
2.设置编号长度域、警告(注意:必须是SAP系统已定意的域)
3.设置缓冲,优点:不直接去数据库里取数,提升效率;缺点:存在跳号
4.设置取数范围
5.调整当前编号
6.调用程序
FORM frm_vbenn_number CHANGING cv_zvbeln.
DATA: lv_object TYPE tnro-object,
lv_nr_range_nr TYPE inri-nrrangenr,
c_zorder(10) TYPE n,
lv_zorder(7) TYPE n,
lv_data(2) TYPE n,
lv_c TYPE string.
CLEAR:c_zorder,lv_zorder,lv_data,lv_c.
lv_data = sy-datum+2(2).
CONCATENATE 'D' lv_data INTO lv_c.
lv_object = 'ZVBELN'. " 对象
lv_nr_range_nr = '01'.
"锁定 NUMBER RANGE 对象
CALL FUNCTION 'NUMBER_RANGE_ENQUEUE'
EXPORTING
object = lv_object
EXCEPTIONS
foreign_lock = 1
object_not_found = 2
system_failure = 3
OTHERS = 4.
" 产生NUMBER RANGE
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = lv_nr_range_nr
object = lv_object
IMPORTING
number = c_zorder
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.
" 解锁 NUMBER RANGE 对象
CALL FUNCTION 'NUMBER_RANGE_DEQUEUE'
EXPORTING
object = lv_object.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = c_zorder
IMPORTING
output = c_zorder.
lv_zorder = c_zorder+3(7).
CONCATENATE lv_c lv_zorder INTO cv_zvbeln.
ENDFORM.