I would like to share a interesting scenario where we are having full data loads (Planning Data) in the infocube on daily basis and our requirement was that the cube should have the latest data load request only and rest should be deleted.
In the standard BI7.0 Package, we have the functionality to delete the overlapping requests in the process chain.
The above functionality does not work because in our scenario we were populating cal/month dynamically in DTP. In the start of a month, month gets populated in the DTP which is different from the last day month/year. For Example Take a case today the date is 31st Jan 2010 so the calmonth/year which gets populated in the DTP would be 012010 and the very next day it would be 022010 as the month gets changed from Jan to Feb and the same problem will come when there would be change in the year then both the month and year would be changed.
This was the problem which we were facing due to this the selection conditions does not remains overlapping and we were getting two requests instead of one which needs to deleted manually.
The second constraint was that they dont want older data in the cube, so we can not keep the older data and we just require current month data in the cube (Data related to planning).
To overcome the above problem we have written the following code in which we are taking all the requests from the cube with reference to the DTP. We are passing the request number and Infocube technical name to the function module RRSM_DELETE_REQUEST and catching all the exceptions for the process chain.
SELECTION-SCREEN BEGIN OF BLOCK 001 WITH FRAME TITLE text-001.
parameters: InfoCube(30) TYPE C OBLIGATORY,
: DTP TYPE STRING OBLIGATORY.
SELECTION-SCREEN END OF BLOCK 001.
TYPES t_rsicount like rsiccont.
data : i_rsicount TYPE STANDARD TABLE OF t_rsicount,
: wa_rsicount like LINE OF i_rsicount,
: req type rsiccont-rnr,
: cnt type i.
TYPES: BEGIN OF tab,
request type rsiccont-rnr,
end of tab.
DATA: i_tab type STANDARD TABLE OF tab,
: wa_tab like LINE OF i_tab.
*****All requests for the Cube into internal Table.****
into table i_rsicount
where ICUBE = Infocube
ORDER BY Timestamp DESCENDING.
*****Filter on all the request as per the DTP on the selection screen.******
loop at i_rsicount INTO wa_rsicount.
select rnr into wa_tab
rnr = wa_rsicount-rnr and
LOGDPID = DTP.
if sy-subrc eq 0.
wa_tab-request = wa_rsicount-rnr.
APPEND wa_tab-request to i_tab.
DESCRIBE table i_tab lines cnt.
if cnt > 1.
*****Request Deletion leaving latest request.******
Loop at i_tab INTO wa_tab.
If sy-tabix ne 1.
if sy-subrc = 0.
req = wa_tab-request.
CALL FUNCTION 'RSSM_DELETE_REQUEST'
REQUEST = req
INFOCUBE = InfoCube
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.
*****Reading the exceptions from the function module.************
CASE SY-SUBRC .
MESSAGE s051(rsar) WITH 'Successfully Done'.
MESSAGE e051(rsar) WITH 'REQUEST_NOT_IN_CUBE'.
MESSAGE e051(rsar) WITH 'INFOCUBE_NOT_FOUND'.
MESSAGE e051(rsar) WITH 'REQUEST_ALREADY_AGGREGATED'.
MESSAGE e051(rsar) WITH 'REQUEST_ALREADY_COMDENSED'.
MESSAGE e051(rsar) WITH 'NO_ENQUEUE_POSSIBLE'.
MESSAGE e051(rsar) WITH 'CUBE_IN_PLANNING_MODE'.
MESSAGE s051(rsar) WITH 'No Request Available for Deletion'.
Thanks & Regards
You can check the code in the wiki also at following link.....