Batch Determination Enhancement in SAP
I was working as a technical consultant at one of the mechanical companies in Pennsylvania in October 2002. I thought the SAP implementation (46C version) there to be a simple one, with minimum tweaks and twists, till I was assigned this requirement of enhancing the SAP Batch Determination.
The elastomer operations in many plants of the company used to blend two or more batches together in order to manufacture uncured elastomer that yielded parts with the appropriate spring rate tolerance. A tool was needed to determine how much of each batch is required to manufacture blends within tolerance. Experience showed that simple tools and hand calculations yielded excessive rework. Standard SAP material quantity calculation was evaluated and found deficient for the following reasons:
- SAP could not easily model the four basic equations in the current blend models:
- Linear (which SAP could model)
- Frequently more than two batches were used for blending. Many of the equations required a recursive solution to accommodate this.
The solution proposed by the functional team was to develop a solution to replace the material quantity calculation for elastomer blends. It involved using batch characteristics from inventory and BOM, quantity information from the created process order, a few custom tables that needed to be created to define the elastomer parameters, and a manual entry of target blend parameters. The output of this user exit was to be a proposal that can be accepted or can be modified by the blender. Upon acceptance of the results, the user exit was to change the exploded BOM on the production order so that these items could be back flushed during manufacture of the blend.
Doesnt this sound simple? Well, not really so when we tried implementing the solution
- The foremost challenge was to understand how the standard material quantity calculation works. That would serve as a starting point and then we wanted to make sure that we are not trying to re-invent the wheel. Understanding the standard system was not so simple. It took us a lot of time, and ensured that we needed something custom-built for our requirement.
- Trying to identify a user exit where the solution could be implemented was yet another challenge.
- The description of the requirement mentioned above is somewhat a simplified version of it. There were many other tweaks making it more and more complex. One such case being where three different batch types were used in order to gain an additional degree of freedom so that the blend could be targeted for two properties instead of one.
- Last but not the least was the complex equations that need to be solved in SAP to arrive at the target blends. They reminded me of those intricate equations in Linear Algebra course in my under-grad!
After a month of iterative discussions with the functional team to understand the requirements and to ensure the technical feasibility of the design, I came to a point where I understood the requirements and started searching extensively for a user-exit to implement the functionality, but could find none. I explored other options as well. Modifying the process order directly via a BDC looked like an option and was proposed to the functional team. The estimates were quickly worked upon and it came to a total of around 60 man-days including testing. The estimates were put in front of the business and you can imagine 60 days for an ABAP program! The requirement was taken out of the current scope with the backing that it is too complex to be implemented in the current phase, and could be looked into at some time in the future.
A new beginning
I was helping this famous worldwide providers of superior quality beverage solutions company in Atlanta with standardizing their North American processes.
One of the companys business line was the manufacture of the juice products. The variation in the crop quality, crop volume and season timing lead to juices and concentrate of variable quality and quantity. Considering this, blending was a key step in manufacturing to get the desired consistency to ensure the business continuity in an optimal manner. A tool was needed to automate this process.
Consider an example where a finished product, say Orange Juice is a blend of the following:
The finished product has a set of key characteristics that determines its usage. Lets assume these to be: Brix, Acidity and Essence. These three properties drive the adjustment in the component quantities of Standard Bill of Material (BOM) for ingredient A, ingredient B and Water, to ensure that the finished goods is within the specification range.
The requirement was very similar to what we discussed earlier except that the components were different, the finished product was different, the tolerances, and the rules were different, but arent such things transparent to a software solution.
I had learnt my lessons from the past. I adopted a very structured approach this time. After getting a birds view of the requirement, I looked up the SAP system to find out the flexibility it offers in the area of batch determination. It was not long before I got hold of the exit XCOM0001, which is a User Exit for Material Quantity Calculation(not sure how we missed it the first time)! From the first look at the interface of the function, it was not clear how I was going to implement our solution using it, but as we went on, it became clearer and clearer. To make it simpler, the exit had a documentation, which I would term as one of the best I have ever seen attached to a standard SAP function. After getting a good understanding of how the exit works, the technical team along with the functional team, went to the plant where the blending, which we had heard of only on paper till now, was being carried out. When the full-blown design workshop ended on the third day, we had a prototype of the solution working! Though the prototype was a simplified version, but we had the heart of the solution already and knew how to go from there. No more excel sheets. No more Fortran programs. Blending could be automated.
Though I would not be listing a step by step solution for enhancing the batch determination here for the reasons of confidentiality, but some of the key points that would help others in implementing a similar requirement are as under:
- XCOM0001 is the exit that can be used for modifying the quantities defaulted from the standard BOM in a process order/recipe. In addition to changing the quantities, it offers other functionalities like defining your own formulae for quantity calculation or calling up external applications like excel for carrying out complex quantity calculations.
- The function exit has a flexible enough interface and has most of the process order details available so that they can be used while making the calculations within the exit. APPLICATION carries the material quantity calculation source. For example, MR for master recipe and 40 for process order
IN_CAUFVD is the process order header structure
IN_COL contains the column structure of the material quantity calculation
IN_ROW contains the line layout
IN_JOIN contains the values and formulae per line
IN_PLPOE contains the operations from the master recipe
IN_STPO contains the BOM components of the material quantity calculation
IN_RESBDGET contains the reservations of the material quantity calculation
IN_AFVGDGET has the operations from the order
IN_ROW_DEF contains the index to the database tables
After doing the calculations, if the formulae or values need to be saved and presented in the standard system, the following needs to be done in the logic:
- Change the required entry in table IN_JOIN. The header quantity is in the first record. The subsequent table entries contain the operation and the component quantities.
- Set the following values:
IN_JOIN-FORM_IND = space.
Import parameter CANGEND_VALUE = “X” to save a value
Import parameter CHANGED = “X” to save a formula
- The important requirement of using this exit is to understand how to read the material quantity calculation tables. Table IN_ROW_DEF represents the sequence of operations and components in the material quantity calculation. It contains an index to a data record in the table for every object. Example:
Oper Item Object ID Table No Index 0014 GA40 2 RESB 3 0010 1 PLPO 1 0012 2 PLPO 2 0012 GA50 0 STPO 1
loop at in_row_def
where tabnm = ‘RESB’.
* Index for access to material quantity calculation line
tabix_tmp = sy-tabix + 1.
* Reading a BOM component
read table in_stpo index in_row_def-index.
* Reading a material quantity calculation line
read table in_row index tabix_tmp.
read table in_join with key row = in_row-id.
* Changing a value, value to be saved later
in_join-value = ‘xxxxx’.
in_join-form_ind = Space.
modify in_injoin index tabix_tmp.
changed_value = ‘X’.