Before loading data to InfoCube or to Data Store Object, sometimes we need to delete data from that dataprovider for a particular selection i.e. using selective deletion and then load the data to InfoCube.
When it is required:
Sometimes before loading data to Infocube/DSO we need to delete data for that particular data range for what we are loading the data. To automate this selective deletion we need to use some variant in process chain to delete data selectively from data target. As there is no SAP given process type is available this has to be done through a different procedure.
Suppose we have a infocube where we need to recalculate some values everyday considering last three weeks. So Duirng everyday’s load there will be some data already present in the cube which need to be reloaded to recalculate the values. In such case we need to delete that particular data range else it will create data duplication in Infocube. In this case we need to delete last three weeks data before loading to Infocube.
How to Do:
- We can achieve this by using “DELETE_FACTS” Transaction code.
- Go to T-code DELETE_FACTS and give InfoCube name. Select Generate selection program option and then execute.
- It will generate the following G Program
- Our target is to delete data for last three weeks. We can achieve this in two ways.
1. Using variant
2. Copying auto generated program into Z program and change inside the code
First Option: Using Variant
- Take this G program and then go to SE38. Give program name and click on Variants
option. Click on Display.
- Give a Variant Techenical name and click on Create. It will go to Values Screen of the Variant.
- Click on Attributes . Give description of the Variant.
- Now find Calendar Day and select on Selection Variable field. Select Type of variable as “D”
- Click on name of variable field and chose Variable which will give option of Current date – XXX, Current Date + YYY option. Enter 21 as XXX and 0 as YYY as we need to delete three weeks data (21 days)
- Then save the variant and you will be able to see the variants with the caledar day values. It is reflecting last 21 days from current day.
- Now add this G program with the created variant in the process chain to delete last three weeks data
Second Option: Changing inside ABAP Program
- Go to SE38 and enter G program in the Program field. Clcik on Copy and copied this SAP generated program into a Custom Z program
- Find 0CALDAY field in the newly copied Z program and change the code so that it takes last 21 days values from current date. Check if this field is Initial (not having any value) and then Pass sy-datum in l_s_range-high and sy-datum – 21 in l_s_range-low field.
- Now this new Z program need to be added in the process chain without variant to delete last three weeks data