SAP Production Planning: Install Custom Function COHV (Part III)

Introduction
The previous two episodes (see part I, see part II) have demonstrated how to create and register a custom mass processing function code in COHV as well as have provided an outline of the actual implementation of the mass processing. However, the implementation has not done anything useful, yet.
Now, it is the time to add some meat to the implementation and dive into more advanced topics like test mode, function parametrization and order updates.
Test mode
Let us start with test mode. Typically, SAP standard mass processing functions provide a test mode option that runs all data processing without actually saving any changes or updates. That is particularly useful if you want to test a mass processing run without committing the updates.

Figure 1 Test mode on

Figure 2 Test mode off
The implementation of the mass processing function does not need to explicitly handle test mode operation, i.e. either to rollback or commit changes. That is done by COHV backbone. Make sure to test thoroughly if the test mode is used to make sure that the custom mass processing function is compatible with the test mode handling in COHV. If you are not sure, the rule of thumb is not to use the test mode.
Passing parameters to the mass processing function
Mass processing functions can be supplied with additional parameters. That is often used in SAP standard functions, and it can be enabled for custom ones.
First, additional parameters need to be added to the transparent table and the dialog structure that have been created in the episode 2. Make sure to add the same fields of the same type to the table and to the structure.

Figure 3 The transparent table with a parameter

Figure 4 The dialog structure with a parameter
Next, the parameter needs to be added to the custom function screen. Again, the screen has already been defined in the previous episode. The easiest way to add parameters is to refer to the dialog structure.

Figure 5 The function’s screen with the parameter
Once that is done, the parameter will appear in COHV.

Figure 6 The function’s parameter in COHV
Mass processing logic implementation
Now, let’s implement the mass processing logic to update production orders. My goal is to change production orders quantity by the value passed with the function parameter. The implementation goes into Z_CO_WORK999_EXEX_SINGLE function. Refer to the previous episode for the details of the function creation.

Figure 7 A snippet of the mass processing logic implementation
Here is the entire implementation of the custom mass processing logic, which consists of the following steps:
- Get a production order number from LS_COWBPAR-OBJNR
- Read the order’s header details with the BAPI_PRODORD_GET_DETAIL function
- Modify the order quantity by the value of the function parameter. It is available in the LS_COWBPAR-QTYCHANGE field
- Update the order with the BAPI_PRODORD_CHANGE function
