Sie sind auf Seite 1von 5

Configure Customer Exits for Intern.

Batch Number Assignment


You can use SAP enhancement SAPLV01Z for internal batch number assignment. This enhancement contains two function module exits that you can use to define number ranges or templates for batch numbers:

EXIT_SAPLV01Z_001. You use this exit to replace the number range object and/or interval proposed by the system with your own number range object and/or interval. In addition, you can, for instance, stop the system from assigning an internal number depending on the material or plant. You can also use this exit to stop the dialog box from appearing. EXIT_SAPLV01Z_002. Using this exit, you can either change the number assigned by the system, or assign your own number.

Further notes Both exits contain a communication structure with application data from the respective business transaction (plant or material type, for example). If you need further information, such as the time, the user name or the date, you must include them yourself in one of the exits. The system always checks whether the assigned batch number already exists in the system. If it does, it terminates the function without assigning a batch number. Example In function module exit EXIT_SAPLV01Z_001, the system uses the material type to determine number range interval XY. This number range is then used to determine number 0000100123 as the next batch number . In function module exit EXIT_SAPLV01Z_002, the final batch number 'ABCD100123' is determined from batch number 0000100123 and plant ABCD. The system suppresses the leading zeros. If you do not use a sequential counter for the batch number, you can skip internal number assignment in exit EXIT_SAPLV01Z_001 to specify your own batch number in exit EXIT_SAPLV01Z_002. Further information and examples for EXIT_SAPLV01Z_001 and EXIT_SAPLV01Z_002 Further information and examples for EXIT_SAPLV01Z_002 Activities 1. Implement the required enhancement. Either create a new project or use an existing one. 2. Activate the project. Your enhancement works only after the project has been activated. Further notes As opposed to modifications, enhancements are release-insensitive as they are not made in the SAP standard version but in name ranges reserved for the customer. For more information on the general procedure for making enhancements, see the enhancement transaction under Utilities -> Online handbook. Each individual enhancement is documented and can be accessed by choosing SAP docu in the enhancement transaction.

Further information and examples for EXIT_SAPLV01Z_001 and EXIT_SAPLV01Z_002 :You can define internal batch number assignment according to your requirements via the enhancement SAPLV01Z with the exits EXIT_SAPLV01Z_001 and EXIT_SAPLV01Z_002 SAP delivers a total of 6 examples for batch number assignment: 1. Copying the production order number to the batch number 2. Copying the sales order number to the batch number 3. Material-type-dependent batch number assignment 4. Material-number-dependent batch number assignment 5. Including the date in the batch number 6. Including the plant number in the batch number For examples 1 and 2 you have to use the exits EXIT_SAPLV01Z_001 and EXIT_SAPLV01Z_002. For examples 3 and 4 you have to use the exit EXIT_SAPLV01Z_001. For examples 5 and 6 you have to use the exitEXIT_SAPLV01Z_002. For a detailed description of the examples, see below. Prerequisites 1. Internal batch number assignment via the customer exit is activated: To do this, in Customizing, choose Logistics general -> Batch management -> Batch number assignment -> Activate internal batch number assignment. 2. Maintaining the number range object Two number range objects are provided for batch number assignment:

o o

Standard number range for batch number assignment BATCH_CLT Number range for material-type-dependent or material-number-dependent batch number assignment BATCH_MAT

Activities 1. Use the SAP enhancement SAPLV01Z: a) In transaction CMOD, create either a new project or use an existing project. b) Add the SAP enhancement SAPLV01Z to the project. 2. Copying the example code: a) Choose Component. b) Choose Change. c) Choose: EXIT_SAPLV01Z_001 for examples 1-4 EXIT_SAPLV01Z_002 for examples 1-2 and 5-6 d) Choose Edit -> Copy SAP source text. The example code is copied to the relevant table in the function module exit. e) To copy the example, remove the comment symbol before the include it pertains to. 3. Activate the project. When you activate the project, the enhancement with the function module exits EXIT_SAPLV01Z_001 and EXIT_SAPLV01Z_002 comes into effect. Examples

Example 1 Copying the production order number to the batch number When a batch is produced, the process order number or production order number is copied as the batch number. This type of assignment is only possible in connection with process orders or production orders. Outwith an order, a number range is determined for batch number assignment. In this example, it is the standard number range BATCH_CLT. If the order has not yet been saved (for example, when a number is assigned when the order is created), a temporary number is created. A message appears prompting you to save the order. The system then assigns an order number which is accepted as the batch number. The system checks whether a batch already exists with this number. If this is the case, the system aborts internal batch number assignment with a corresponding error message. Note: In this example, note that the include LXVBZB21 in EXIT_SAPLV01Z_002 has to be activated at the same time, as actual batch numbers are not assigned until this is activated. Example 2 Copying the sales order number to the batch number If a batch number is assigned in connection with a sales order, the sales order number is accepted as the batch number. If there are no sales orders, a number range object is defined with a number range from which the batch number is taken. If a batch already exists with this sales order number, the batch number is assigned externally. Note: In this example, note that the include LXVBZB22 in EXIT_SAPLV01Z_002 has to be activated at the same time before actual number assignment can take place. Example 3 Material-type-dependent batch number assignment In the number range object BATCH_MAT a separate sub-object is created for each material type. Note that the number range object is maintained accordingly or batch number assignment cannot take place. For example, if the material "flour" belongs to raw materials, it is maintained in the sub-object ROH, and the batch number is taken from the same number range as the material "eggs" which also belongs to the raw materials group. Example 4 Material-number-dependent batch number assignment

In material-number-dependent batch number assignment, materials that are handled in batches must be maintained in the table BNMAT, which specifies the assignment of the material to the number range. If there is no assignment in the table, the system aborts batch number assignment. An error message appears informing you that batch number assignment is not possible and specifying the table that has to be maintained. Each material number is assigned a number range object, a sub-object, and a number range in the table BNMAT. This is how each material receives its own batch number range. The number range object BATCH_MAT is an example of this. The material numbers are divided into groups via their material type that match the sub-object. Each material number is then assigned its own number range by table BATCH_MAT. The number ranges used must be maintained in the number range object. Examples 5 and 6 Including the date or plant number in the batch number The number ranges for the batch numbers must be defined in a way that ensures that no characters are overwritten by the templates.

Further information and examples for EXIT_SAPLV01Z_002 :Coding example for internal batch number assignment via EXIT_SAPLV01_002 Use You use this exit to change a batch number that has been assigned or assign a batch number if assignment was suppressed in the exit EXIT_SAPLV01Z_001. Integration You can define internal batch number assignment according to your requirements via the enhancement SAPLV01Z with the exits EXIT_SAPLV01Z_001 and EXIT_SAPLV01Z_002. SAP delivers a total of 6 examples for batch number assignment: 1. Copying the production order number to the batch number 2. Copying the sales order number to the batch number 3. Material-type-dependent batch number assignment 4. Material-number-dependent batch number assignment 5. Including the date in the batch number 6. Including the plant number in the batch number For examples 1 and 2 you have to use the exits EXIT_SAPLV01Z_001 and EXIT_SAPLV01Z_002. For examples 3 and 4 you have to use the exit EXIT_SAPLV01Z_001. For examples 5 and 6 you have to use the exit EXIT_SAPLV01Z_002.

For a detailed description of the examples, refer to the documentation for EXIT_SAPLV01Z_001. Prerequisites 1. Internal batch number assignment via the customer exit is activated: To do this, in Customizing, choose Logistics general -> Batch management -> Batch number assignment -> Activate internal batch number assignment. 2. Maintaining the number range object: Two number range objects are provided for batch number assignment:

o o

Standard number range for batch number assignment BATCH_CLT Number range for material-type-dependent or material-number-dependent batch number assignment BATCH_MAT

Procedure 1. Create the enhancement in transaction CMOD: a) Create either a new project or use an existing project. b) Add the SAP enhancement SAPLV01Z to the project. 2. Activate the project: When you activate the project the enhancement comes into effect. 3. Transferring the example code: a) Choose Enhancement components. b) Choose Change. c) Choose EXIT_SAPLV01Z_002. d) Choose Edit -> Copy SAP source text. The example code is copied to the relevant include of the function module exit. e) Remove the comment symbol before the include it pertains to. Note: Examples 5 and 6: Selecting the batch number with the date or plant number The first characters of the batch number are overwritten by a template. The date and the plant number are used as the template. The number range must be defined in a way that ensures that no characters are overwritten by the templates. Example: Preliminary batch number: 0000001234 Number range: 1-9999 Template date: JJJJWW New batch number: JJJJWW1234