流水号操作(一)- 获取 Number Range
TCode:SNRO。
1 *&---------------------------------------------------------------------* 2 *& Form frm_get_ref_nr 3 *&---------------------------------------------------------------------* 4 * 获取 Number Range 5 *----------------------------------------------------------------------* 6 * -->PV_NR text 7 *----------------------------------------------------------------------* 8 FORM frm_get_ref_nr USING pv_nr. 9 10 "锁定 Number Range 对象 11 CALL FUNCTION 'NUMBER_RANGE_ENQUEUE' 12 EXPORTING 13 object = 'ZBC_BOX' "创建对象 14 EXCEPTIONS 15 foreign_lock = 1 16 object_not_found = 2 17 system_failure = 3 18 OTHERS = 4. 19 20 "产生Number Range 21 CALL FUNCTION 'NUMBER_GET_NEXT' 22 EXPORTING 23 nr_range_nr = '3' 24 object = 'ZBC_BOX' "创建对象 25 IMPORTING 26 number = pv_nr 27 EXCEPTIONS 28 interval_not_found = 1 29 number_range_not_intern = 2 30 object_not_found = 3 31 quantity_is_0 = 4 32 quantity_is_not_1 = 5 33 interval_overflow = 6 34 buffer_overflow = 7 35 OTHERS = 8. 36 37 "解锁 Number Range 对象 38 CALL FUNCTION 'NUMBER_RANGE_DEQUEUE' 39 EXPORTING 40 object = 'ZBC_BOX'. 41 42 IF sy-subrc <> 0. 43 * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 44 * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 45 ENDIF. 46 47 ENDFORM. "FRM_GET_NR