Number Range - SNRO
by P surjith kumar, Enteg Infotech, Bangalore, India.
Number Range Object - SNRO
In an Invoice creation number range is the one which refer to unique invoice. This is vital to identify the specific invoice. The custom define Number Range Object can be create in the Transaction Code SNRO and the object has to be called in program with the help of a Function Module NUMBER_GET_NEXT.
In an Organization for the custom defines applications like invoice generation, reimbursement or Expense payment, etc. needs auto generated number for reference, which is done through a Number Range object. The creation and the implementation of Number Range Object based on the Employee's Company code and the current Year is explained in this article.
Creating Number Range Step by Step
The following steps are necessary to create a Number Range,
- Log to Transaction Code SNRO.
- Number Range Object Creation.
- Assigning Domain and the Sub-object for Number Range Object.
- Assigning Sub-object for Number Range Object.
- Assigning Number for the Number range Object
- Implementation of Number range Object.
- Execution and viewing the newly generated Number Range.
1) Log to Transaction Code SNRO
Give a name for the Number Range Object.
2) Number Range Object Creation
Once the name given for the Number Range Object,
click the create icon to create the number range Object as shown below.
3) Assigning Domain and the Sub-object for Number Range Object
Once the create icon is clicked the below mentioned screen will appear.
Then the value has to enter in Subobject data element, Number length domain and Warning % as mention below.
Then Same Screen Explained in Detail below,
a) Short and Long Description
a short and long description for the Number Range.
b) Interval Characteristics
Subobject data element: This determines whether the number range intervals distinguish subobjects.
Enter the Company code data element "BUKRS" for the subject, like Company code Personnel area and other field can be entered as per the requirement.
To-year flag: If the check box is selected this Flag will set and it determining, whether the number range intervals are distinguished according to the financial year.
Number length domain: Assign the (Domain) Data type and length for the Number range.
Enter the data type "NUM10" or as per the requirement.
No interval rolling: If the check box is select the flag will set and it prevents the number range object intervals from automatically starting from the beginning at the upper limit.
c) Customizing Specifications
Number range transaction: Transaction code to call number range maintenance is assigned. And it Dependencies is this transaction code is automatically entered in the transaction code table.
Warning %: This indicates the Percentage of numbers remaining in a number range, once the percentage is reached it will show a warning. For Examples if you have defined an interval from 1 to 100 and you want to issue a warning at the number 90, you have to enter 10 (%) here.
Enter the warning Percentage (%) "10". If the requirement is "15" or "5" assign the given value here.
Main memory buffering: Selecting the flag determines whether the number intervals are buffered for assignments and checks.
The number interval buffer is in the Shared Memory of the application server. Each buffer is used to store the external number intervals and a certain number (subinterval) of the internal number intervals. If the numbers of an internal number interval are used up, numbers are taken from the database via the number range server. The status of the number interval in the database is increased by the number of numbers fetched to the buffer.
When buffering number intervals, gaps may result in number assignment. Buffering is therefore not possible for applications, which require continuous number assignment.
No. of numbers in buffer: This number which you assign determines how many numbers are reserved in the application server buffer for the intervals.
d) Group Specification
Group table: Name of the table for number range groups.
Benefits: Number range intervals are identified uniquely by a number range number. When numbers are assigned or checked, the number range group elements determine the number range interval via the number range number. Number range group elements are assigned in the group table.
Subobject field in group table: It is Number range table subobject field name, the Field name of the group table containing the subobject if the group table takes subobjects into account.
Fld NoRangeElement: It is Name of the number range element field, During assignment and checking of number range numbers, the number range group elements determine the number range interval via the number range number. For Example For the material master, the material type determines the number range interval. Here, the element field is the material type field.
Fields int./ext. no.range no.: Name of the number range field (in the group table), which contains the internal number range number.
Fld. NoRangeNo: Field name of the group table, which contains the number range number.
Display element text: Mention the Short text for number range object maximum 20 characters.Once the SubObject name, Domain (Length & Data type) and warning % is entered save the changes.
After saving, a message window will appear as below and Click yes.
Then the same screen will appear as shown below.
4) Assigning Sub-object for Number Range Object.
Then a new screen will appear as shown below.
Enter the Company "IN01" and Click the Intervals.
5) Assigning Number for the Number range Object
Then a new screen will appear as below.
Once the numbers assigned then Press Enter.
And the below screen will appear.
Then save it a message widow will appear as mentioned below.
Then click the Tick Mark.
Then the number range object can be used your application. If any changes need to made
Then the Number range Object is called inside the Program or function module or Inside the method of Webdynpro Component, etc.
6) Implementation of Number range Object.
Number range with Sub-Object and Year Dependency used in the program is explained below.
a) Go to Transaction Code - SE38
Enter the Title of the Program.
Save and write the below Program to get the Number range
b) Call the Number Range Object in the Program using the Function Module "NUMBER_GET_NEXT".
*&---------------------------------------------------------------------* *& Report YSURJITH_NORANGE *&---------------------------------------------------------------------* * Created by: P SURJITH KUMAR, Enteg Infotech, Bangalore * Version : 1.0 * Purpose : Number Range for Invoice Generation *&---------------------------------------------------------------------* REPORT YSURJITH_NORANGE. DATA: LV_NUMBER_RANGE(10) TYPE N, "-- Variable to hold Newly generated Number Range LV_YEAR TYPE INRI-TOYEAR, "-- Variable to hold Year LV_SUBOBJECT TYPE T001-BUKRS, "-- Variable to hold Company Code LV_RC TYPE INRI-RETURNCODE. "-- Variable to hold the Return Code LV_YEAR = '2008'. "--- Assign Current Year LV_SUBOBJECT = 'IN01'. "--- Assign the Company Code CALL FUNCTION 'NUMBER_GET_NEXT' EXPORTING NR_RANGE_NR = '01' "-- This hold the Newly generated Number OBJECT = 'YINVNUM' "---- Passing the Number Range Object SUBOBJECT = LV_SUBOBJECT "-- Pass the Company code TOYEAR = LV_YEAR "-- Pass the Year IMPORTING NUMBER = LV_NUMBER_RANGE "-- Newly generated Number RETURNCODE = LV_RC "-- The Return Code 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 : / 'The New Number is :'(001), LV_NUMBER_RANGE, / 'The Return Code is :'(002), LV_RC.
*&--- End of Report YSURJITH_NORANGE -- ---&*
Then Save and Activate the Program, then execute it.
Return Code (lv_rc)
1) lv_rc = ' ' , Everything is working fine
2) lv_rc = '1', The assigned number lies in the critical area.
3) lv_rc = '2', This was the last number, next time the first number will be assigned
7) Execution and viewing the newly generated Number
Then Execute and get the output as below,
The same Program you can assign in your application as per your Requirement.