In general, the serial number is generated according to the defined rules. The following describes how to generate a serial number:
1. Set the serial number in the system
Use T-code snro to create a serial number to identify an object,
Enter the object zlc_001 and click Create.
Enter short text, long text, number length domain to writeProgramIt should be created separately. Here we will use the domain matnr of the item number for testing. Other parameters can use the default value, and then save the input data.
A message is displayed, indicating that the sub-object is successfully created. You need to maintain a sub-object and click "number range ".
Click "interval" to maintain the specific serial number rules.
Save and set the serial number. The next step is how to obtain the serial number in the program.
2. Get the serial number in the program
Report zlc_number_range.
Data w_matnr type matnr.
Start-of-selection.
Call function 'Number _ range_enqueue'
Exporting
Object = 'zlc _ 001' "ceate with snum
Exceptions
Foreign_lock = 1
Object_not_found = 2
System_failure = 3
Others = 4.
Call function 'Number _ get_next'
Exporting
Nr_range_nr = '00'
Object = 'zlc _ 001'
Importing
Number = w_matnr
Exceptions
Interval_not_found = 1
Number_range_not_intern = 2
Object_not_found = 3
Quantity_is_0 = 4
Quantity_is_not_1 = 5
Internal_overflow = 6
Others = 7.
Call function 'Number _ range_dequeue'
Exporting
Object = 'zlc _ 001 '.
If SY-SUBRC <> 0.
Message ID SY-MSGID type SY-MSGTY number SY-MSGNO
With SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
Endif.
Repeat the screen field:
Data Field (50 ).
Field-Symbols: <F1> type any, <F2> type any.
Data I _no (10) type N.
Clear I _no.
Call function 'Number _ get_next'
Exporting
Nr_range_nr = '00'
Object = 'zlc _ 001'
Importing
Number = I _no.
Field = 'I _no '.
Assign (field) to <F1>.
Field = '(saplmigo) GOHEAD-XBLNR'. "saplmigo program name; GOHEAD-XBLNR screen Field
Assign (field) to <F2>.
<F2 >=< F1>.