1 DATA:l_num TYPE p LENGTH 4 .
2
3 SELECT SINGLE *
4 INTO @DATA(ls_snro)
5 FROM zsd_snro
6 WHERE name = 'ZSD_JS'
7 AND snro = 'ZSDJS'.
8
9 *每天重置流水号
10 IF ls_snro-zdate <> sy-datum OR ls_snro IS INITIAL .
11
12 CALL FUNCTION 'NUMBER_RANGE_INTERVAL_INIT'
13 EXPORTING
14 object = 'ZSDJS'
15 * SUBOBJECT = ' '
16 * INTERVALS =
17 * CLIENT = SY-MANDT
18 * COMMIT =
19 EXCEPTIONS
20 no_interval_found = 1
21 object_not_found = 2
22 OTHERS = 3.
23 IF sy-subrc = 0.
24
25 COMMIT WORK AND WAIT .
26 ls_snro-name = 'ZSD_JS' .
27 ls_snro-snro = 'ZSDJS'.
28 ls_snro-zdate = sy-datum .
29 MODIFY zsd_snro FROM ls_snro .
30 IF sy-subrc = 0 .
31 COMMIT WORK .
32 ELSE .
33 ROLLBACK WORK .
34 ENDIF .
35
36 ENDIF.
37
38 ENDIF .
39
40 *加锁
41 CALL FUNCTION 'NUMBER_RANGE_ENQUEUE'
42 EXPORTING
43 object = 'ZSDJS'
44 EXCEPTIONS
45 foreign_lock = 1
46 object_not_found = 2
47 system_failure = 3
48 OTHERS = 4.
49
50 IF sy-subrc = 0.
51 "获取下个数字
52 CALL FUNCTION 'NUMBER_GET_NEXT'
53 EXPORTING
54 nr_range_nr = '1'
55 object = 'ZSDJS'
56 IMPORTING
57 number = l_num
58 EXCEPTIONS
59 interval_not_found = 1
60 number_range_not_intern = 2
61 object_not_found = 3
62 quantity_is_0 = 4
63 quantity_is_not_1 = 5
64 interval_overflow = 6
65 buffer_overflow = 7
66 OTHERS = 8.
67 IF sy-subrc = 0.
68
69 "解锁
70 CALL FUNCTION 'NUMBER_RANGE_DEQUEUE'
71 EXPORTING
72 object = 'ZSDJS'
73 EXCEPTIONS
74 object_not_found = 1
75 OTHERS = 2.
76
77 ENDIF.
78
79 ENDIF.