Last active
October 11, 2015 07:07
-
-
Save JouryJonkergouw/2f3732926eb48cfce127 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATA: | |
l_t_rsiccont TYPE STANDARD TABLE OF rsiccont, | |
lv_ftimestampc TYPE c LENGTH 14, | |
lv_ttimestampc TYPE c LENGTH 14, | |
lv_frtimestamp TYPE rstimestmp, | |
lv_totimestamp TYPE rstimestmp, | |
lv_calweek TYPE /bi0/oicalweek, | |
lv_first_date TYPE scal-date, | |
lv_last_date TYPE scal-date. | |
CONSTANTS: | |
lc_begin_time TYPE c LENGTH 6 VALUE '000000', | |
lc_end_time TYPE c LENGTH 6 VALUE '235959', | |
lc_dso TYPE rsinfocube VALUE 'ZJJ_DSO_NAME'. | |
FIELD-SYMBOLS: | |
<lfs_rsiccont> TYPE rsiccont. | |
*- Convert system date to calendar week. | |
CALL FUNCTION 'ZBW_DATE_TO_ANYTHING' | |
EXPORTING | |
i_calday = sy-datum | |
IMPORTING | |
e_calweek = lv_calweek. | |
*- Get week first and last day. | |
CALL FUNCTION 'WEEK_GET_FIRST_DAY' | |
EXPORTING | |
week = lv_calweek | |
IMPORTING | |
date = lv_first_date | |
EXCEPTIONS | |
week_invalid = 1 | |
OTHERS = 2. | |
*- Define last day of the week | |
lv_last_date = lv_first_date + 6. | |
*- Concatenate to a string with format YYYYMMDDHHIISS | |
CONCATENATE lv_first_date lc_begin_time INTO lv_ftimestampc. | |
CONCATENATE lv_last_date lc_end_time INTO lv_ttimestampc. | |
*- Convert the from and to string to a timestamp format | |
*- Needed to select data from the RSICCONT | |
lv_frtimestamp = lv_ftimestampc. | |
lv_totimestamp = lv_ttimestampc. | |
*- Select all requests which are currently in the data monitor | |
SELECT rnr timestamp FROM rsiccont | |
INTO CORRESPONDING FIELDS OF TABLE l_t_rsiccont | |
WHERE icube EQ lc_dso | |
AND timestamp BETWEEN lv_frtimestamp AND lv_totimestamp. | |
*- If we start ASCENDING then the oldest requests will be | |
*- deleted including the ones till the current date. | |
SORT l_t_rsiccont BY timestamp DESCENDING. | |
*- Start looping over the requests. | |
LOOP AT l_t_rsiccont ASSIGNING <lfs_rsiccont>. | |
*- Delete requests from the DSO | |
CALL FUNCTION 'RSSM_DELETE_REQUEST' | |
EXPORTING | |
request = <lfs_rsiccont>-rnr | |
infocube = lc_dso | |
dialog = abap_false | |
EXCEPTIONS | |
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. | |
* Uncomment if you want to enable error handling | |
* IF sy-subrc <> 0. | |
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno | |
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. | |
* ENDIF. | |
ENDLOOP. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment