1.使用T-code:SNRO创建一个流水号标识对象
输入Tcode SNRO 后进入如上图所示的Number Range Object Maintenance界面,输入Object名称,点击新建。
进入创建界面,如上图所示,输入Short text、Long text和Number length domain;若每新年度开始时编号也从头开始,则可勾选To-year flag;若编号达到最大也不自动重新开始,则可勾选No interval rolling,输入Warning % 95,表示流水后用到95%是会发出警告。点击保存。
点击Number Range。
点击Change Intervals.
点击Insert Interval。
在Insert Interval界面输入New Interval的No. 、From number、To number后点击Insert。
这样流水号就设定完成。
2.如何在程序中取得流水号
1 REPORT ZTEST. 2 DATA: L_SEQNO TYPE C LENGTH 4. 3 CALL FUNCTION 'NUMBER_RANGE_ENQUEUE' 4 EXPORTING 5 OBJECT = 'ZTEST01' 6 EXCEPTIONS 7 FOREIGN_LOCK = 1 8 OBJECT_NOT_FOUND = 2 9 SYSTEM_FAILURE = 3 10 OTHERS = 4 11 . 12 IF SY-SUBRC <> 0. 13 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 14 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 15 ENDIF. 16 17 CALL FUNCTION 'NUMBER_GET_NEXT' 18 EXPORTING 19 NR_RANGE_NR = '01' 20 OBJECT = 'ZTEST01' 21 * QUANTITY = '1' 22 * SUBOBJECT = ' ' 23 * TOYEAR = '0000' 24 * IGNORE_BUFFER = ' ' 25 IMPORTING 26 NUMBER = L_SEQNO 27 * QUANTITY = 28 * RETURNCODE = 29 EXCEPTIONS 30 INTERVAL_NOT_FOUND = 1 31 NUMBER_RANGE_NOT_INTERN = 2 32 OBJECT_NOT_FOUND = 3 33 QUANTITY_IS_0 = 4 34 QUANTITY_IS_NOT_1 = 5 35 INTERVAL_OVERFLOW = 6 36 BUFFER_OVERFLOW = 7 37 OTHERS = 8 38 . 39 IF SY-SUBRC <> 0. 40 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 41 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 42 ENDIF. 43 44 CALL FUNCTION 'NUMBER_RANGE_DEQUEUE' 45 EXPORTING 46 OBJECT = 'ZTEST01' 47 EXCEPTIONS 48 OBJECT_NOT_FOUND = 1 49 OTHERS = 2 50 . 51 IF SY-SUBRC <> 0. 52 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 53 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 54 ENDIF. 55 56 WRITE: L_SEQNO.