Dynamic Selective Deletion From Infocubes
Dynamic Selective Deletion From Infocubes
Dynamic Selective Deletion From Infocubes
Applies to:
SAP Business Intelligence (BI 7.0). For more information, visit the EDW homepage.
Summary
This article is intended to help in providing a customized solution for doing selective deletion from Infocubes. The selection criteria could be some kind of lookup, business logic or any dynamic selection criteria on dates etc .This selective deletion can be automated using Process Chains. Author: Rakesh Kumar
Author Bio
Rakesh Kumar is a SAP BI/BO Consultant currently working with AG Technologies Pvt. Ltd (Mumbai/INDIA). He has over 5+ years of experience in various BW/BI/BO/SEM-BPS implementation/Support projects.
Table of Contents
Selective Deletion from Infocube ........................................................................................................................ 3 Standard way of doing selective deletion ........................................................................................................ 3 Using Program RSDRD_DELETE_FACTS .................................................................................................... 5 Customized solution for dynamic selective deletion ....................................................................................... 5
Selective deletion internal table structure .................................................................................................................... 5 Lookup Logic................................................................................................................................................................ 6 Defining ranges for Infoobjects .................................................................................................................................... 6 Creation of Complete Selective Deletion Program Z_SEL_DELETE_INFOCUBE_XXX_XXX .................................... 7 Calling the Program in Process Chains ..................................................................................................................... 10 Precaution .................................................................................................................................................................. 10
This kind of selective deletion would help you deleting on basis of certain hardcoded values of characteristics.
Now when you click on Start, it will create a background job for you for doing selective deletion. If you want you can use recurring parameter and do the repetitive selective deletion.
Using Program RSDRD_DELETE_FACTS This program can help you to do selective deletion similar to first approach. Difference lies here that you can generate your own programs which you can use in Process Chains for daily scheduling unlike jobs created above. For more details on this you can refer link: Selective deletion through Process Chains Customized solution for dynamic selective deletion If you have a scenario where you are looking up from a DSO/Master Data table, with your filter logic and you want to delete on the basis of that. In this case the above standard solution would not help you. To illustrate the point better, see the below mentioned graphic:
Note: Selective Deletion Program would read data of DSO/Master Data Table and on the basis of business logic, delete the data from any infocube.
Selective deletion internal table structure The structure of the internal table should be carefully decided taking into account the characteristic values to be used in selective deletion. Say for example you have following data in the Infocube:
Qty 10 20 34 65 83
Value 15 40 34 130 83
*structure of selective deletion internal table TYPES: BEGIN OF TY_DELTAB , MAT_PLANT TYPE /BI0/OIMATERIAL, PLANT TYPE /BI0/OIPLANT,
END OF TY_DELTAB. TABLES : /BI0/PMAT_PLANT. DATA: IT_DELTAB TYPE TABLE OF TY_DELTAB. DATA: WA_DELTAB LIKE LINE OF IT_DELTAB.
Lookup Logic First be ready with your lookup logic. In my case, matplant master data table is being read on certain selection criteria into an internal table IT_DELTAB. This internal table IT_DELTAB works as the basis of selective deletion. Selection query on matplant table. You can write your own selection query here
SELECT MAT_PLANT PLANT from /BI0/PMAT_PLANT into corresponding fields of table IT_DELTAB where PLANT = '1000' AND ( MAT_PLANT BETWEEN '000000000000000132' AND '000000000000000235' ).
You can do some more manipulation here may be for dates etc. Example select those material where posting date > 20110101.
Defining ranges for Infoobjects The Infoobjects defined in structure of selective deletion internal table should be added in this section .Variables should be defined for each characteristics and the same can be used in MOVE statement, example MOVE lv_mat TO L_S_RANGE-LOW. lv_mat is variable for holding material number information. *This is crucial section of the code .The following code can be copied and used *for other characteristics as well. *Here it is used for material and plant ******************************************************************************** *****************
L_SX_SEL-IOBJNM = '0MATERIAL'. CLEAR L_S_RANGE. MOVE 'I' TO L_S_RANGE-SIGN. MOVE 'EQ' TO L_S_RANGE-OPTION. MOVE lv_mat TO L_S_RANGE-LOW. MOVE '' TO L_S_RANGE-HIGH. MOVE 'X' TO L_S_RANGE-KEYFL. APPEND L_S_RANGE TO L_SX_SEL-T_RANGE. INSERT L_SX_SEL INTO TABLE L_THX_SEL.
CLEAR L_SX_SEL. L_SX_SEL-IOBJNM = '0PLANT'. CLEAR L_S_RANGE. MOVE 'I' TO L_S_RANGE-SIGN. MOVE 'EQ' TO L_S_RANGE-OPTION. MOVE lv_plant TO L_S_RANGE-LOW. MOVE '' TO L_S_RANGE-HIGH. MOVE 'X' TO L_S_RANGE-KEYFL. APPEND L_S_RANGE TO L_SX_SEL-T_RANGE. INSERT L_SX_SEL INTO TABLE L_THX_SEL.
*add more characteristics for changing the selection criteria ******************************************************************************** For any other Infoobject say ZIOBJ write this piece of code. First declare variable then the range for Infoobject. Refer to the Complete Program section.
Data : lv_ziobj type /bic/oiziobj. CLEAR L_SX_SEL. L_SX_SEL-IOBJNM = 'ZIOBJ'. CLEAR L_S_RANGE. MOVE 'I' TO L_S_RANGE-SIGN. MOVE 'EQ' TO L_S_RANGE-OPTION. MOVE lv_ziobj TO L_S_RANGE-LOW. MOVE '' TO L_S_RANGE-HIGH. MOVE 'X' TO L_S_RANGE-KEYFL. APPEND L_S_RANGE TO L_SX_SEL-T_RANGE. INSERT L_SX_SEL INTO TABLE L_THX_SEL.
Creation of Complete Selective Deletion Program Z_SEL_DELETE_INFOCUBE_XXX_XXX Goto SE38 and Create this Program Z_SEL_DELETE_INFOCUBE_XXX_XXX .Here the XXX_XXX holds for your Infocube to undergo selective deletion (Just a naming convention which I follow).You use the below mentioned code:
REPORT Z_SEL_DELETE_INFOCUBE_0IC_C03. *----------------------------------------------*Created by..: Rakesh Kumar *Company: AG Technologies Pvt. Ltd. *-----------------------------------------------
L_TYPE(1) L_PARALLEL L_NO_OF_ROWS L_NO_OF_ROWS_C(10) L_TITEL L_TEXT1 L_TEXT2 L_S_RANGE L_S_SELTXT L_SX_SEL L_T_MSG L_THX_SEL L_T_SELTXTS
TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE
C, I, I, C, RS_CHAR72, RS_CHAR72, RS_CHAR72, RSDRD_S_RANGE, RSDQ_S_SELTEXT, RSDRD_SX_SEL, RS_T_MSG, RSDRD_THX_SEL, RSDQ_T_SELTEXT WITH HEADER LINE.
*Declare l_bi parameter, if no BIA index exists DATA: L_BI TYPE RS_BOOL. DATA L_PA(2) TYPE N. DATA L_P1(1) TYPE C. DATA L_NL(1) TYPE C. *structure of selective deletion internal table TYPES: BEGIN OF TY_DELTAB , MAT_PLANT TYPE /BI0/OIMATERIAL, PLANT TYPE /BI0/OIPLANT,
END OF TY_DELTAB. TABLES : /BI0/PMAT_PLANT. DATA: IT_DELTAB TYPE TABLE OF TY_DELTAB. DATA: WA_DELTAB LIKE LINE OF IT_DELTAB. *selection criteria from lookup dso/master data table. SELECT MAT_PLANT PLANT from /BI0/PMAT_PLANT into corresponding fields of table IT_DELTAB where PLANT = '1000' AND ( MAT_PLANT BETWEEN '000000000000001309' AND '000000000000001319' ).
*declare variables for different characteristics DATA: Lv_mat type string, LV_plant type string. CLEAR L_SX_SEL. LOOP AT IT_DELTAB INTO WA_DELTAB. clear L_THX_SEL. clear lv_mat. clear lv_plant. CLEAR L_SX_SEL. lv_mat = wa_deltab-mat_plant.
lv_plant = wa_deltab-plant. *This is crucial section of the code .The following code can be copied and used for other characteristics as well ******************************************************************************** L_SX_SEL-IOBJNM = '0MATERIAL'. CLEAR L_S_RANGE. MOVE 'I' TO L_S_RANGE-SIGN. MOVE 'EQ' TO L_S_RANGE-OPTION. MOVE lv_mat TO L_S_RANGE-LOW. MOVE '' TO L_S_RANGE-HIGH. MOVE 'X' TO L_S_RANGE-KEYFL. APPEND L_S_RANGE TO L_SX_SEL-T_RANGE. INSERT L_SX_SEL INTO TABLE L_THX_SEL.
CLEAR L_SX_SEL. L_SX_SEL-IOBJNM = '0PLANT'. CLEAR L_S_RANGE. MOVE 'I' TO L_S_RANGE-SIGN. MOVE 'EQ' TO L_S_RANGE-OPTION. MOVE lv_plant TO L_S_RANGE-LOW. MOVE '' TO L_S_RANGE-HIGH. MOVE 'X' TO L_S_RANGE-KEYFL. APPEND L_S_RANGE TO L_SX_SEL-T_RANGE. INSERT L_SX_SEL INTO TABLE L_THX_SEL. *add more characteristics for changing the selection criteria ******************************************************************************** L_PARALLEL = 1. L_NL = RS_C_FALSE. *actual selective deletion using L_THX_SEL internal table CALL FUNCTION 'RSDRD_SEL_DELETION' EXPORTING I_DATATARGET = '0IC_C03' I_THX_SEL = L_THX_SEL I_AUTHORITY_CHECK = RS_C_TRUE I_NO_LOGGING = L_NL I_PARALLEL_DEGREE = L_PARALLEL I_SHOW_REPORT = '' I_WORK_ON_PARTITIONS = '' I_REBUILD_BIA = '' I_WRITE_APPLICATION_LOG = 'X' CHANGING C_T_MSG = L_T_MSG. ENDLOOP.
Calling the Program in Process Chains It is the simplest step in the complete solution. Goto RSPC, create Process Chain (F5) or edit existing (CTRL+F9).Select General Services ABAP Program
Enter the Name of the Program and dont enter anything for variant.
Precaution If you have indexes built on the relevant Infocube, make sure to delete index before running this program and rebuilding of indexes after this selective deletion.
Related Content
Using Selective Deletion in Process Chains.pdf Scheduling selective deletion in process chain - (info cube..) Selective Deletion through Process Chains For more information, visit the EDW homepage