Sometimes we have to do a snapshot load via transformation recalculating all the the bucket aging key figures in transformation logic. This is generally required in case we have aging reports for which we desire better reporting performance as buckets are precalculated for each day.
In such cases we cannot restrict any of the source time characterics to particular value as we require aging right from the start of business. Adding to it if we do a multiple data loads on same day there would be no basis for overlapping deletion. One typical example of such transformation is as below :
As we see below aging buckets are calculated per day, with Calander day = sy-datum in target.
Solution to automate this Scenario :
Making use of standard function module : RSSM_DELETE_REQUEST.
This function module takes the target cube name and request number as input. The cube name would always be fixed but the request number would always be dynamic. Hence Request number will be dervied via sql statements on RSPCPROCESSLOG & RSICCONT table in an ABAP program. Logics as explained in the ABAP code.
ABAP program logic :
li_RSICCONT TYPE STANDARD TABLE OF RSICCONT,
lwa_rspcprocesslog TYPE rspcprocesslog,
lwa_RSICCONT TYPE RSICCONT.
DATA: lc_REQUEST TYPE RSREQDONE-RNR.
parameters : p_vari TYPE RSPC_VARIANT,
p_cube type RSINFOCUBE.
INTO TABLE li_rspcprocesslog
WHERE batchdate = sy-datum
AND variante = p_vari.
IF li_rspcprocesslog IS NOT INITIAL.
SELECT * from RSICCONT into table li_RSICCONT for all entries in li_rspcprocesslog where RNR = li_rspcprocesslog-instance.
IF SY-SUBRC = 0.
LOOP AT li_rspcprocesslog INTO lwa_rspcprocesslog.
read table li_RSICCONT into lwa_RSICCONT with key RNR = lwa_rspcprocesslog-instance.
IF SY-SUBRC = 0.
MOVE lwa_rspcprocesslog-instance to lc_REQUEST.
CALL FUNCTION ‘RSSM_DELETE_REQUEST’
REQUEST = lc_REQUEST
INFOCUBE = p_cube
REQUEST_NOT_IN_CUBE = 1
INFOCUBE_NOT_FOUND = 2
REQUEST_ALREADY_AGGREGATED = 3
REQUEST_ALREADY_COMDENSED = 4
NO_ENQUEUE_POSSIBLE = 5
CUBE_IN_PLANNING_MODE = 6
OTHERS = 7
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
Now this program needs to be part of process chain BEFORE the DTP run for this snapshot target as shown below.