Skip to Content

How to delete overlapping requests DSO using ABAP except loads from source DSO

After reading this great blog from J. Jonkergouw on his website about Delete overlapping requests DataStore Object using ABAP, we had a similar issue, however we needed to keep one historic load in the DSO. That’s why we altered the code a bit to keep requests from one DSO.

Kudos to the code of Joury, very nice to implement.

     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 scaldate,

       lv_last_date   TYPE scaldate.

     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’,

       lc_dso_out    TYPE rsinfocube VALUE ‘ZRB_DSO_NAME’.

     FIELD-SYMBOLS:

            <lfs_rsiccont> TYPE rsiccont.

*-  Convert system date to calendar week.

     CALL FUNCTION ‘ZBW_DATE_TO_ANYTHING’

       EXPORTING

         i_calday  = sydatum

       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

*- The adjustment made is an inner join from the request table

*- which stores the source of the DTP and is filtered out in the where class

     SELECT rnr timestamp FROM rsiccont AS p

     INNER JOIN rsbkrequest AS r ON r~request = p~rnr

     INTO CORRESPONDING FIELDS OF TABLE l_t_rsiccont

     WHERE icube EQ lc_dso

     AND NOT src EQ lc_dso_out

     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.

Be the first to leave a comment
You must be Logged on to comment or reply to a post.