See how you can use conditional execution in your process chains to halt additional transactional data loads when you have outdated master data.
Key Concept
In SAP NetWeaver BI 7.0, the data transfer process (DTP) supports error handling for DataStore objects. The system sorts failed data load records and writes them to a temporary request- based database table called the error stack. This allows you to determine the processing step in which the error occurred. You can display the error stack records from the monitor of the data transfer process request. After you resolve the error, it is easier to restart failed loads from the error stack using an error DTP.
Consider a scenario in which SAP NetWeaver BI receives outbound shipment data from the legacy system via flat files written to the application server daily. Until the legacy system is retired, the business plans to keep pushing legacy shipment records into SAP NetWeaver BI.
The flat files contain data for the material (legacy material number), customer, and shipment quantities. The transformation from the flat file into a DataStore object (DSO) maps the legacy material to the SAP material via a lookup. The InfoObject for the material (0MATERIAL) has an attribute, which I call NAMATLEG (legacy material). The master data management (MDM) team populates this attribute in SAP ERP Central Component (ECC) in the material master table MARA. You can then extract NAMATLEG as an attribute of 0MATERIAL into SAP NetWeaver BI.
If no mapping of NAMATLEG to an SAP material exists in the InfoObject 0MATERIAL, the system treats the shipment record as an error record to post to the error stack. You can design the process chain to check for records in the error stack and stop further execution until the MDM team fixes the master data. Subsequently, you can execute the error data transfer process (error DTP) to load the records from the error stack. The process chain permits a delta pull from ECC or SAP NetWeaver BI only if the system has posted the error stack records via an error DTP.
I’ll explain how I applied this technique to a scenario in which I have two values for a material: the legacy system value of A123456 and the ECC value of 10012345. Then I’ll show you how to implement this technique in SAP NetWeaver BI 7.0.
Note
Refer to my article,
“Conditional Execution: One Process Chain Does the Work of Two,” for the method to combine monthly and daily process chains into one using Business Add-Ins (BAdIs). Part 1 shows you how to create a formula in the Formula Builder transformation library to test if the current date and the last Saturday of the month are the same to facilitate monthly snapshot loads. You can find this article in the BI hub of SAPexperts.
In my example, the MDM team loads the legacy material number into the field BISMT in table MARA in ECC. The flat files are loaded daily to the DSO NAPS_O01. The legacy material (BISMT) is mapped to the InfoObject NAMATLEG in NAPS_O01.
A DTP loads shipment data to an intermediate DSO, NAPS_O02. This DSO contains a key field MATERIAL which refers to the SAP material in ECC. The transformation (from NANP_O01 to NANP_O02) uses the active master data tables (/BI0/PMATERIAL) to find the SAP material that corresponds to the legacy material number (NAMATLEG).
In my example, the flat file has a legacy material A123456 in the shipment records. The MDM team uses transaction MM01 to create an SAP material 10012345. The MDM team should update the old material number field BISMT with the value A123456 in the material record for 10012345. If the MDM team has not updated the master data records in ECC, the lookup for the SAP material fails and the system posts the transaction record to the error stack.
Before the next data load, the process chain ensures that the error DTP has processed the error records. This is important so that the delta quantity loads are posted to NANP_O02 correctly. It requires that the MDM team assign an SAP material value to all missing legacy materials and that you re-extract the material master data into SAP NetWeaver BI.
In Figure 1, the Decision Between Multiple Alternatives process type provides two options:
- Option 1: The process chain proceeds only if no error stack records exist
- Option 2: The process chain stops with error if it encounters an error stack from the previous load

Figure 1
Process chain setup for conditional execution
In my example, the process chain checks to see if the error stack exists from the prior load to NAPS_O02 before it loads legacy system shipment data. If it finds records in the error stack, the process chain fails before the system can pull the legacy data for the next day.
The error stack records are created in SAP NetWeaver BI in the DTP load from NAPS_O01 to NAPS_O02 as shown in the rule details in Figure 2. The code reads the internal table to see if material master table /BI0/PMATERIAL has legacy material mapped to the ECC material number. If the read statement cannot find an SAP material match, the system posts the record to the error stack.

Figure 2
Code in material transformation to send the records to the error stack if legacy material map is not found in 0MATERIAL
After the first data load from ECC to SAP NetWeaver BI into NAPS_O01, the system loads the data to the DSO NAPS_O02 via a predefined DTP. No records exist in the error stack at this point. The process chain passes through the Decision Between Multiple Alternatives process type in which a BAdI checks for the error stack records.
If error stack records are created in the first pull from ECC, the process chain fails the test condition in the Decision Between Multiple Alternatives process type before the system executes the next delta pull. At this point, the MDM team is notified of the materials for which the legacy-to-SAP material mapping is missing. This could be done via email to the responsible team member. Alternatively, you could automate the process chain with an ABAP program to read the records in the error stack and initiate an email.
After the MDM team fixes the data, run the error DTP to load the failed records. These records now load successfully and the error stack is cleared. When you re-run the process chain, it passes the Decision Between Multiple Alternatives process type test, which indicates that there are no error stack records. The system executes the next delta pull from ECC.
Implement the Technique
Incorporate user-defined functions into the Formula Builder transformation library using the BAdI RSAR_CONNECTOR. In part 1 of this series, I explained how you add a formula to the Formula Builder transformation library, which allows the system to use the formula as needed.
Now I’ll focus on the code in the BAdI that creates a test condition to check for records in the error stack. In part 1, I created an implementation of RSAR_CONNECTOR. For this example, I add the method ERROR_STACK_EXISTS to the same implementation because I created these formulas to use in process chains. You can create a separate implementation for each formula if you prefer.
The first step is to modify the already defined implementation ZRSAR_ CONNECTOR. Use transaction SE18, enter RSARCONNECTOR, and select Enhancement Implementation>Overview. In the screen that appears, select the existing implementation ZRSAR_CONNECTOR and click on the change icon (Figure 3).

Figure 3
Select the implementation to modify
On the following screen, deactivate the implementation ZRSAR_CONNECTOR, edit the code as shown in Figure 4, and reactivate the implementation (see part 1 for details). You can download this code by clicking this link.
* technical name of function as seen on Formula Builder l_function-tech_name = 'C_ERROR_STACK_EXISTS'. * description as seen of Formula Builder l_function-descriptn = 'Check if error stack exists' . * Class implemented for BADI l_function-class = 'ZCL_CHECK_ERROR_STACK'. * Function name in class for checking if error stack exists l_function-method = 'CHECK_ERRORSTACK_BEFORE_LOAD' . Append l_function to c_operands.
|
Figure 4 |
Code to create the new formula in the transformation library |
Using transaction SE24, create a new class ZCL_CHECK_ERROR_STACK with the method CHECK_ERROR_STACK_BEFORE_LOAD (Figure 5). Set Level to Instance, set Visibility to Public, and enter a Description (for my example, I entered Check Error Stack Exists). Each method belonging to the class can have input and output parameters depending on the functionality required.

Figure 5
Define the method CHECK_ERROR_STACK_BEFORE_LOAD in the Methods tab
Place your cursor on the method CHECK_ ERROR_STACK_BEFORE_LOAD in Figure 5 and click on the Parameters button. In the screen that appears, define the input and output parameters as shown in Figure 6.

Figure 6
Input and output parameters for the CHECK_ERROR_STACK_BEFORE_LOAD method
To make the function generic and reusable in different process chains, the interface for the method has an input parameter P_TARGET. The value of the input parameter defines the data target where you need to check for the error stack. In my example, it is the DSO NAPS_O02. In this data provider, you check for the existence of the error stack from the previous load. The output parameter, ERROR_ STACK_EXISTS returns a 0 if there are no records in the error stack. It has a value of 1 if an error stack exists.
Click on the Methods button and then double-click on CHECK_ERROR_ STACK_BEFORE_ LOAD. In the screen that appears enter the code to check if the error stack exists. You can download the code for this step by clicking this link. Place the code between method CHECK_ERROR_STACK_BEFORE_LOAD…. endmethod (Figure 7).

Figure 7
Enter the code to check existence of error stack records
Activate the class by clicking on the activate icon. You should now see the function C_ERROR_STACK_EXISTS in Formula Builder, as shown in Figure 8.

Figure 8
Add the formula to the process chain
Now I’ll revert to the original problem of using this formula in the process chain. Use transaction RSPC to revert to your process chain that you want to execute conditionally. In this scenario, the process chain is in Figure 1. The chain is designed to load data into NAPS_O01 from ECC (raw data) and then map the legacy material to the SAP material in the load to NAPS_O02. The first step involves the check for the existence of an error stack from the load to NAPS_O02, if any.
From the General Services section on the left side of the screen, select the Decision Between Multiple Alternatives process type and drag it into the right window. In the window that opens up, enter a variant name ERROR_STACK_ EXISTS4.
On the following screen, in the first row (command If), enter the text Error Stack Absent (Figure 9). Click on the create icon in the Formula column. In the screen that appears, enter the following test condition, as shown in Figure 10:

Figure 9
Click on the formula icon to enter the test condition
1 - C_ERROR_STACK_EXISTS( 'NAPS_O02') = 1

Figure 10
Formula for the IF command
Recall that the input parameter P_TARGET is set to NAPS_O02 to the formula in the custom function module in Figure 6.
In the formula in Figure 10 1 - C_ERROR_ STACK_EXISTS( ‘NAPS_O02’) has two possible values:
- 1 if no error stack exists
- 0 if an error stack exists
The system compares this value with the right side of the equality, which is always 1.
If no error stack exists, both sides have a value of 1, which yields a Boolean True, whereby the system selects option 1 in Figure 1 for the multiple alternatives. The process chain permits a flat file load, as shown in Figure 9.
If an error stack exists, the right side of the equality yields a 0, which when compared to the left side value of 1, yields a Boolean False. Then the system selects option 2 (error) from the multiple alternatives in Figure 1, and the process chain errors out, as shown in Figure 9.
After saving the Decision Between Multiple Alternatives process type, proceed to create the rest of the process chain as shown in Figure 1. After you create the process chain, you can schedule the process chain based on your needs. In this example, I run the chain daily. When the system creates an error stack as the result of missing mapping of the legacy material to the SAP material, the system notifies the MDM team to correct the error.
After the MDM team fixes the error in ECC and notifies the BI team, the BI team re-extracts the 0MATERIAL master data first. Then you execute the error DTP to clear the error stack. At that point, you re-run the process chain from its failed step to complete the shipment data load for that day.
Rajiv Kalra
Rajiv Kalra is an independent SAP consultant with more than 11 years of SAP experience. With more than five years of BI experience in data modeling, design, configuration, and performance tuning of BI systems, he has helped develop many out-of-the-box solutions to resolve complicated reporting requirements at various client sites. Besides SAP NetWeaver BI, Rajiv has worked on the ERP side for more than seven years and is an SAP-certified ABAP consultant.
You may contact the author at kalrar_99@yahoo.com.
If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.