SAP Production Planning: Install Custom Function COHV (Part II)
Introduction
In the previous piece, I demonstrated how to create and register a custom mass processing function code in COHV. Now I will describe how to implement the function.
SAP standard mass processing functions are implemented with COWORK<code> function groups, e.g. the function group COWORK230 implements the mass processing function 230 Close.
I am going to copy the function group COWORK170 to a custom function group and implement the custom mass processing logic there. Before that, let us execute a couple of preliminary steps.
I am trying to keep to SAP naming convention throughout all the subsequent steps.
Dialog structure creation
Copy the COWORK170_SETUP structure to ZCOWORK999_SETUP with SE11.
Parameters database table creation
Copy the COWB170PAR database table to ZCOWB999PAR in SE11.
Function group ZCOWB999 creation
Function group ZCOWB999 adjustments
Now we need scan the ZCOWB999 function group and replace all the artifacts of the standard COWB170 function group with our custom objects:
The easiest way to do that is to search the source code of the ZCOWB999 function group for WORK170 string.
Here are my changes:
Register custom function modules
Recall the previous article that showed how to register the custom mass processing function with Z_COHV_CUSTOM_FUNCTIONS enhancement. Now, we need to register each function of the ZCOWB99 function group there.
Custom processing logic
As we have copied the function group ZCOWB999 from SAP standard COWB170, for now it works exactly the same way as SAP original and executes the same mass processing logic. The mass processing logic starts at line 129 and ends at line 219 of the Z_CO_WORK999_EXEC_SINGLE function.
Let us replace that with same trivial test custom logic:
As you see my custom logic is just to log a message without any actual updates to an order. The goal here is to make sure that each order select in COHV is processed by the function, that its number is correctly recognized and that the function correctly logs processing messages.
Testing
I am running COHV and choosing my 999 custom mass processing function.
Next, I am selecting a couple of production orders and execute the mass processing function:
Finally, I am displaying the processing log:
As you can see each of the selected orders have been processed by the Z_CO_WORK999_EXEC_SINGLE function, which logged the message.
Wrap up
The article presents a straightforward method to implement custom mass processing functions in the COHV transaction. Naturally, real life scenarios require actual production order updates, not just logging messages. The updates can be posted by production order BAPIs for instance.
We will look under the hood of mass processing in the part III and explore more advanced topics like how the functions work together, processing parameterization or test mode. Be sure to join us for Part III as we explore these exciting insights further!