ABAP--如何创建和使用sap的号码范围对象
创建号码范围对象:
1. 使用TCODE:SNRO (Simple way to remember is SapNumberRangeObject).
2. 输入号码范围对象的名称 并点击“新建”按钮.
3. 输入描叙和相关字段具体参见下图:
Warning% à Assume that an interval is defined from 1 to 1000. If you want to issue a warning at the number 900, enter 10 (%) here.
4. 点击“SAVE”按纽.系统将弹出下列屏幕:
5. 点击“YES”按钮,并制定对象类.
6. 点击“Number Ranges” .
7. 点击 “Change Intervals”.
8. 点击 “Insert Interval”.
9. 输入相应的数据值,参见下屏:
10. 点击 “Insert”,再点击保存.号码范围对象就已经成功建立.
测试the Number Range Object:
We can use the function module, NUMBER_GET_NEXT, to get the next number of any number range object.
Following is a test program to get the next available number of the object created above:
REPORT zsnro_test.
DATA:
NUMBER TYPE I.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01'
object = 'ZDEMO'
IMPORTING
NUMBER = NUMBER
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
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Write :/ 'Next available number is: ', Number.
Source URL:http://www.saptechnical.com/Tutorials/ABAP/SNRO/SNRO.htm