Professional Documents
Culture Documents
Applies to:
SAP Business Intelligence 7.0. For more information, visit the EDW homepage.
Summary
This article describes about to analyze the all PSA table in the system and to delete the PSA records dynamically. Author: Sreenivas Nannuri Company: Accenture Private Ltd. Created on: 21 September 2011
Author Bio
Sreenivas Nannuri is working with Accenture Private Ltd. since 1.8 years. He is currently working on SAP BI 7.0 He also worked on different areas in BI like modeling, reporting, Information broadcasting, production support, ETL process.
Custom Program to Analyze the PSA & Delete the PSA Records Dynamically
Table of Contents
1) 2) 3) 4) 5) 6) Introduction ............................................................................................................................................ 3 Benefits of managing PSA data deletion ............................................................................................... 3 ABAP Code: ........................................................................................................................................... 3 Input screen for the program: ................................................................................................................ 7 Output: ................................................................................................................................................... 8 Cross checking the PSA table: .............................................................................................................. 9
Custom Program to Analyze the PSA & Delete the PSA Records Dynamically
1) Introduction
In most cases, data that is staged in PSA should be deleted periodically. It helps to delete data in an organized way that will be easy to manage and maintain. How often the data should be deleted and what methods can be employed for the deletion of data will be discussed in this article. An ABAP program is presented that will help in identifying the how many records in PSA tables and can delete the records from the psa table dynamically from the output.
3) ABAP Code:
The following ABAP program comes in handy to determine which PSAs are not being managed.
REPORT
TABLES: rstsods, ICON. TYPE-POOLS: slis. TYPES: BEGIN OF ty_display, tabname TYPE rstsods-odsname, count TYPE rscewcount, odsname(20) TYPE c, records TYPE nrows, REQUEST TYPE RSREQUNR, END OF ty_display, BEGIN OF ty_function, request TYPE RSTSODSREQUEST-REQUEST, END OF ty_function, BEGIN OF ty_rsreqicods, tabname TYPE rsreqicods-tabname, timestamp TYPE rsreqicods-timestamp, req_date TYPE sy-datum, END OF ty_rsreqicods, BEGIN OF ty_rstsods, odsname TYPE rstsods-odsname, odstech TYPE rstsods-odsname_tech, dateto TYPE rstsods-dateto, END OF ty_rstsods. DATA: odsname TYPE RSODSNAME. DATA: wa_display TYPE ty_display, tb_display TYPE TABLE OF ty_display, tb_function TYPE TABLE OF ty_function, wa_function TYPE ty_function, wa_rsreqicods TYPE ty_rsreqicods, wa_rstsods TYPE ty_rstsods, t_display TYPE STANDARD TABLE OF ty_display INITIAL SIZE 0,
Custom Program to Analyze the PSA & Delete the PSA Records Dynamically
t_rsreqicods TYPE STANDARD TABLE OF ty_rsreqicods INITIAL SIZE 0, t_rstsods TYPE STANDARD TABLE OF ty_rstsods INITIAL SIZE 0, i_icon_del LIKE icon-id, text(20) TYPE c, va_check TYPE c. DATA: PSA_NAME1 TYPE tabname, psa_name type RSODSNAME, PICK TYPE SY-UCOMM.
SELECTION-SCREEN BEGIN OF BLOCK B1. SELECT-OPTIONS: s_tabnm FOR rstsods-odsname. PARAMETERS: p_date LIKE sy-datum OBLIGATORY DEFAULT sy-datum. PARAMETERS: p_cnt TYPE c AS CHECKBOX DEFAULT 'X' . SELECTION-SCREEN END OF BLOCK b1. START-OF-SELECTION. DATA: lc_timestamp(14) TYPE c, l_timestamp TYPE rsreqicods-timestamp. CONCATENATE p_date '000000' INTO lc_timestamp. l_timestamp = lc_timestamp. SELECT tabname timestamp INTO TABLE t_rsreqicods FROM rsreqicods WHERE timestamp < l_timestamp AND typ = 'O' AND tabname in s_tabnm. IF sy-subrc <> 0. WRITE: / 'No matching records found.'(001). EXIT. ENDIF. LOOP AT t_rsreqicods INTO wa_rsreqicods. lc_timestamp = wa_rsreqicods-timestamp. wa_rsreqicods-req_date = lc_timestamp(8). MODIFY t_rsreqicods FROM wa_rsreqicods TRANSPORTING req_date. ENDLOOP. SELECT odsname odsname_tech dateto INTO TABLE t_rstsods FROM rstsods WHERE odsname IN ( SELECT DISTINCT tabname FROM rsreqicods WHERE timestamp < l_timesta mp AND typ = 'O' AND tabname in s_tabnm ). SORT t_rstsods BY odsname dateto. LOOP AT t_rsreqicods INTO wa_rsreqicods. CLEAR wa_display. wa_display-tabname = wa_rsreqicods-tabname. wa_display-count = 1. READ TABLE t_rstsods WITH KEY odsname = wa_rsreqicods-tabname TRANSPORTING NO FIELDS BINARY SEARCH. IF sy-subrc = 0.
Custom Program to Analyze the PSA & Delete the PSA Records Dynamically
LOOP AT t_rstsods INTO wa_rstsods FROM sy-tabix. IF wa_rstsods-odsname <> wa_rsreqicods-tabname. EXIT. ENDIF. IF wa_rstsods-dateto >= wa_rsreqicods-req_date. wa_display-odsname = wa_rstsods-odstech. EXIT. ENDIF. ENDLOOP. ENDIF. COLLECT wa_display INTO t_display. ENDLOOP. LOOP AT t_display INTO wa_display. IF wa_display-odsname <> ''. *& Does the table really exist in the DB? SELECT tabname INTO wa_display-odsname FROM dd02l UP TO 1 ROWS WHERE tabname = wa_display-odsname. ENDSELECT. IF sy-subrc = 0. IF p_cnt = 'X'. SELECT COUNT(*) INTO wa_display-records FROM (wa_display-odsname). ENDIF. ELSE. *& Table doesn't exist. Put paranthesis to indicate so. CLEAR wa_display-records. CONCATENATE '(' wa_display-odsname ')' INTO wa_display-odsname SEPARATED BY space. ENDIF. MODIFY t_display FROM wa_display. ENDIF. ENDLOOP. IF p_cnt = 'X'. SORT t_display BY records DESCENDING. ELSE. SORT t_display BY count DESCENDING. ENDIF. start-of-selection. SELECT SINGLE id INTO i_icon_del FROM icon WHERE name = 'ICON_DELETE'. WRITE: / 'ICON',15 'TABLE NAME', 50 'ODS COUNT' , 68 'ODS NAME',90 'NO OF RECO RDS'. WRITE: / SY-ULINE.
Custom Program to Analyze the PSA & Delete the PSA Records Dynamically
LOOP AT t_display INTO wa_display. WRITE:/ i_icon_del HOTSPOT, ' ', wa_display-tabname, ' ', wa_display-COUNT, ' ', wa_display-ODSNAME, ' ', wa_display-RECORDS, sy-uline. ENDLOOP. AT LINE-SELECTION. CASE PICK. WHEN PICK. READ CURRENT LINE FIELD VALUE wa_display-tabname INTO PSA_NAME1. READ CURRENT LINE FIELD VALUE wa_display-odsname INTO PSA_NAME. * UNPACK l_logsys TO l_logsys. if psa_name1 is not initial. REFRESH tb_function. SELECT REQUEST FROM RSTSODSREQUEST INTO TABLE tb_function where ODSNAME EQ psa_name1. LOOP AT tb_function INTO wa_function. DO TB_FUNCTION TIMES. IF psa_name is not initial and wa_function-request is not initial. CALL FUNCTION 'RSDU_PSA_DELETE' EXPORTING I_TABLNM = PSA_NAME I_REQUEST = wa_function-request * EXCEPTIONS * PSA_DELETE_FAILED = 1 * OTHERS = 2 . IF SY-SUBRC EQ 0. va_check = 'X'. ENDIF. ENDIF. CLEAR wa_function. ENDLOOP. * ENDO. CLEAR wa_display. IF va_check EQ 'X'. WRITE: 'SELECTED ROW PSA RECORDS DELETED SUCESSFULLY'. ENDIF. else. exit. ENDIF. ENDCASE. ***************************************************************************************************************************
* *
Custom Program to Analyze the PSA & Delete the PSA Records Dynamically
Custom Program to Analyze the PSA & Delete the PSA Records Dynamically
5) Output:
Custom Program to Analyze the PSA & Delete the PSA Records Dynamically
Then execute the table, you will get the following popup, Click on Number of entries pushbutton you will get the pop up with number of records table holding in the database.
Custom Program to Analyze the PSA & Delete the PSA Records Dynamically
Related Content
You must include at least 3 references to SDN documents or web pages. https://help.sap.com https://sdn.sap.com 1) Step by Step Procedure to Create Broadcasters, to Schedule and to Enhance of SAP- BI Queries from Query Designer. 2) Trigger the Process Chain by ABAP Program and how to Schedule ABAP Program as Background Job
Custom Program to Analyze the PSA & Delete the PSA Records Dynamically