Handling deleted nodes in BW hierarchy
There might be instances where the user might be deleting transactions in the source system (master or transaction data). When the user deletes the records which contain special characters, then the situation gets a little tricky.
For eg, if you are loading a hierarchy and you have a special character in let’s say the Material Number. You can mark this material for deletion/set the deletion indicator in SAP ECC but they will still appear each time you load the data into BW (Full Load). Or you can archive the record.
Below is an approach to handle such a scenario
User created a material number (17B10486*C) with a special character in the ECC system. The hierarchy data loads for this material fails in BW (0MATERIAL_LPRH_HIER).
To avoid this data load failure, we can write a code (CMOD)in the exit EXIT_SAPLRSAP_004. This code replaces this material number with a string DONOTUSE. The condition for replacing this material number is
- The material number is marked for deletion ie the deletion flag is set to ‘X’
- The material number or Node name starts with ‘17B1048’
(if there are more than one material number with the above condition the string to replace is set to DONOTUSE001, DONOTUSE002 etc.)
Below is the hierarchy after the code is implemented. The node with the special character is replaced with DONOTUSE001, DONOTUSE002 etc.
DATA: L_HIER_STRUCT LIKE C_T_HIENODE,
L_HIER_NODE like C_T_HIENODE-NODENAME.
DATA: L_TABIX(4) type n,
L_LVORM like MARA-LVORM.
L_TABIX = 0.
LOOP AT C_T_HIENODE INTO L_HIER_STRUCT.
*Select materials from mara table and check if it has the deletion
*indicator as ‘X’ and the material number has the pattern ’17B1048′
SELECT SINGLE LVORM FROM MARA INTO L_LVORM
WHERE MATNR = L_HIER_STRUCT-NODENAME.
IF L_LVORM = ‘X’ and L_HIER_STRUCT-NODENAME(7) = ’17B1048′.
* Material name is replaced with ‘DONOTUSE and A counter
*is used to suffix this to avoid duplicate names
* eg. DONOTUSE001, DONOTUSE002,
L_TABIX = L_TABIX + 1.
concatenate ‘DONOTUSE’ L_TABIX into C_T_HIENODE-NODENAME.
modify C_T_HIENODE transporting NODENAME.