cancel
Showing results for 
Search instead for 
Did you mean: 

Delete Request using a Routine in the Scheduler

i807185
Associate
Associate
0 Kudos

Hi all,

I have an infocube. Data are loaded into this cube on a <b>weekly basis</b> according to the following requirements.

Example:

Let's assume <b>we are in April</b>and <b>April has 4 weeks</b>:

<b>Week 1 of April</b> - Data for week 1 are loaded

<b>Week 2 of April</b> - Data for week 1 and 2 are loaded

(request for week 1 is deleted)

<b>Week 3 of April</b> - Data for week 1, 2 and 3 are loaded

(request for week 2 is deleted which were the data for week 1 and 2)

On the <b>2nd day of the following Month (in our example this would be May 2nd) Data for week 1, 2, 3, and 4 of April are loaded.</b>(request for week 3 is deleted which were the data for week 1, 2 and 3).

<b>These April data</b> (loaded on the second day of the following month) <b>should stay in the cube then and not be deleted any more.</b>

The procedure for the following Months (i.e. for May etc) should be the same.

This means

<b>Week 1 of May</b> - Data for week 1 are loaded

<b>Week 2 of May</b> - Data for week 1 and 2 are loaded

(request for week 1 is deleted)

etc.

On the <b>2nd day of the following Month (in our example this would be June 2nd) Data for week 1, 2, 3, and 4 of May are loaded.</b>(request for week 3 is deleted which were the data for week 1, 2 and 3).

<b>These May data</b> (loaded on the second day of the following month) <b>should stay in the cube then and not be deleted any more.</b>

CAN ANYBODY HELP ME WITH THIS REQUIREMENT AND TELL ME HOW I CAN DO THAT?

CAN I DO THAT USING A ROUTINE IN THE SCHEDULER ON TAB DATA TARGETS TO DELETE THE REQUEST BASED ON THE LOGIC DESCRIBED ABOVE? DOES ANYONE HAVE SAMPLE CODE FOR THAT?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Christian,

The logic of determination of requests to be deleted is very simple:

When you have got sorted list of requests (descending order), loop at the list, compare the month of the 1st request with this of the 2nd. If the months are the same, delete the 2nd req. Do nothing if they are differenet. Exit loop after that.

You'll delete the requests that loaded data for previous weeks of the same month and leave in the cube requests for previous months with full 4-week data.

Best regards,

Eugene

i807185
Associate
Associate
0 Kudos

Hi Eugene,

do you have some sample code of what this routine to delete requests could look like.

I am not that experienced with ABAP.

Thanks

Christian

edwin_harpino
Active Contributor
0 Kudos

hi Christian,

from service.sap.com/bi

hope this helps.

User Exit after Data loading

(a) Delete old request

REPORT Z_RSSM_START_SECOND_PROCESS_1 .

TABLES: RSREQDONE, " Request-Data

RSSELDONE, " Selection for current Request

RSICCONT. " Request posted to which InfoCube

DATA: L_T_SELDONE LIKE RSSELDONE OCCURS 0 WITH HEADER LINE.

DATA: L_T_ICUBE LIKE RSICCONT OCCURS 0 WITH HEADER LINE.

DATA: L_LOGSYS LIKE RSSELDONE-LOGSYS.

DATA: L_SOURCE LIKE RSSELDONE-SOURCE.

DATA: L_SELDATE LIKE RSSELDONE-SELDATE.

DATA: L_SELTIME LIKE RSSELDONE-SELTIME.

DATA: BEGIN OF L_T_RNR_DEL OCCURS 0,

ICUBE LIKE RSICCONT-ICUBE,

RNR LIKE RSSELDONE-RNR,

END OF L_T_RNR_DEL.

PARAMETER I_RNR LIKE RSREQDONE-RNR.

***********************

SELECT SINGLE * FROM RSSELDONE WHERE

RNR = I_RNR.

IF SY-SUBRC <> 0. "new rquest does not exist, wrong rnr !!!

EXIT.

ENDIF.

SELECT * FROM RSICCONT INTO TABLE L_T_ICUBE WHERE

RNR = I_RNR.

IF SY-SUBRC <> 0. "New request is not posted to any IC

EXIT. "nothing will be deleted

ENDIF.

L_SOURCE = RSSELDONE-SOURCE.

L_LOGSYS = RSSELDONE-LOGSYS.

L_SELDATE = RSSELDONE-SELDATE.

L_SELTIME = RSSELDONE-SELTIME.

SELECT * FROM RSSELDONE INTO TABLE L_T_SELDONE WHERE

SOURCE = L_SOURCE AND

LOGSYS = L_LOGSYS.

DELETE L_T_SELDONE WHERE

RNR = I_RNR. "new request will be deleted

DELETE L_T_SELDONE WHERE "delete younger requests

SELDATE > L_SELDATE OR

( SELTIME > L_SELTIME AND

SELDATE = L_SELDATE ).

*Sort

SORT L_T_SELDONE BY SELDATE DESCENDING SELTIME DESCENDING.

REFRESH L_T_RNR_DEL.

LOOP AT L_T_SELDONE. " Requests to be deleted

LOOP AT L_T_ICUBE. " Request existing in InfoCubes

SELECT SINGLE * FROM RSICCONT WHERE

ICUBE = L_T_ICUBE-ICUBE AND

RNR = L_T_SELDONE-RNR. "check if posted to IC's

IF SY-SUBRC = 0.

L_T_RNR_DEL-ICUBE = L_T_ICUBE-ICUBE.

L_T_RNR_DEL-RNR = L_T_SELDONE-RNR.

APPEND L_T_RNR_DEL.

ENDIF.

ENDLOOP.

IF NOT L_T_RNR_DEL[] IS INITIAL. " something found for rnr

EXIT.

ENDIF.

ENDLOOP.

LOOP AT L_T_RNR_DEL.

CALL FUNCTION 'RSSM_DELETE_REQUEST'

EXPORTING

REQUEST = L_T_RNR_DEL-RNR

INFOCUBE = L_T_RNR_DEL-ICUBE

EXCEPTIONS

REQUEST_NOT_IN_CUBE = 1

INFOCUBE_NOT_FOUND = 2

REQUEST_ALREADY_AGGREGATED = 3

REQUEST_ALREADY_COMDENSED = 4

OTHERS = 5.

IF SY-SUBRC <> 0.

  • open for error-handling

ENDIF.

ENDLOOP.