Child pages
  • Cleaning the RSECADMIN change log tables
Skip to end of metadata
Go to start of metadata

Purpose

To describe how to clean up the analysis authorization change log tables. 

Overview

The change log tables RSECVAL_CL, RSECHIE_CL, RSECTXT_CL, RSECUSERAUTH_CL, and RSECSESSION_CL can grow very large over time and can lead to poor performance.

How to use Report

Execute the report Z_RSEC_DELCHLOG in SE38

Report

*&---------------------------------------------------------------------*
*& Report  Z_RSEC_DELCHLOG
*&---------------------------------------------------------------------*
*& Entries in the BW authorization change log tables RSECVAL_CL,
*& RSECHIE_CL, RSECTXT_CL, RSECUSERAUTH_CL, and RSECSESSION_CL
*&---------------------------------------------------------------------*

report  Z_RSEC_DELCHLOG.

tables: RSECSESSION_CL.

data: begin of it_session occurs 0,
   SESSIONID like RSECSESSION_CL-SESSIONID.
data: end of it_session.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
parameters:
P_TEST type C default 'X' as checkbox.
SELECTION-SCREEN END OF BLOCK B1.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME.
parameters:
P_T1 TYPE C AS CHECKBOX ,
P_T2 TYPE C AS CHECKBOX ,
P_T3 TYPE C AS CHECKBOX ,
P_T4 TYPE C AS CHECKBOX ,
P_T5 TYPE C AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK B2.

data:
L_NR type I,
L_SESSIONID like RSECSESSION_CL-SESSIONID,
L_COUNT1(10) type P,
L_COUNT2(10) type P,
L_COUNT3(10) type P,
L_COUNT4(10) type P,
L_COUNT5(10) type P,
L_ERRCOUNT(10) type P,
L_COUNTER(10) type P.

select-options:
SO_DATE for RSECSESSION_CL-CRDATE obligatory.

start-of-selection.

  perform RECORD_COUNT.
  if P_TEST eq 'X'.
    format color col_heading.
    write: / 'Test mode program will end.'.
    exit.
  endif.

  write: / 'Start processing', SY-DATUM, SY-UZEIT.

  if P_T1 ne 'X' and
     P_T2 ne 'X' and
     P_T3 ne 'X' and
     P_T4 ne 'X' and
     P_T5 ne 'X'.
    format color col_total.
    write: / 'No table selected. Processing ends'.
    exit.
  endif.

  select SESSIONID into table it_SESSION from RSECSESSION_CL where
  CRDATE in SO_DATE.
  " We want to use commit work every X records, that´s why and IT is used

  loop at it_session.
    if P_T1 = 'X'.
      perform DELETE_FROM_TABLE using 'RSECVAL_CL'.
    endif.

    if P_T2 = 'X'.
      perform DELETE_FROM_TABLE using 'RSECHIE_CL'.
    endif.

    if P_T3 = 'X'.
      perform DELETE_FROM_TABLE using 'RSECTXT_CL'.
    endif.

    if P_T4 = 'X'.
      perform DELETE_FROM_TABLE using 'RSECUSERAUTH_CL'.
    endif.

    if P_T5 = 'X'.
      perform DELETE_FROM_TABLE using 'RSECSESSION_CL'.
    endif.

  L_Counter = l_counter + 1.

  if L_counter > 20000 .
     write : / '20.000 record processed'.
     clear L_counter.
     commit work.
  endif.

endloop.

commit work.

format color col_positive.
  write: / 'Records deleted:', L_COUNT1, L_COUNT2, L_COUNT3, L_COUNT4, L_COUNT5.
  write: / 'Number of warnings:', L_ERRCOUNT.
  format color col_key.
  write: / 'Processing ends:', SY-DATUM, SY-UZEIT.

*&---------------------------------------------------------------------*
*&      Form  RECORD_COUNT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form RECORD_COUNT .
  select count(*) into L_NR  from RSECSESSION_CL where CRDATE in SO_DATE.
  write: / 'Numbers of records in RSECSESSION_CL for a given date:', L_NR.
  if L_NR eq 0.
    format color col_negative.
    write: / 'No records found in RSECSESSION_CL for the given date.'.
    exit.
  endif.

endform.                    " RECORD_COUNT

*&---------------------------------------------------------------------*
*&      Form  DELETE_FROM_TABLE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0139   text
*----------------------------------------------------------------------*
form DELETE_FROM_TABLE  using P_TABLENAME.
  delete from (P_TABLENAME) where SESSIONID = it_session-SESSIONID.
  if SY-SUBRC eq 0.
    case P_TABLENAME.
      when 'RSECVAL_CL'.
        L_COUNT1 = L_COUNT1 + 1.
      when 'RSECHIE_CL'.
        L_COUNT2 = L_COUNT2 + 1.
      when 'RSECTXT_CL'.
        L_COUNT3 = L_COUNT3 + 1.
      when 'RSECUSERAUTH_CL'.
        L_COUNT4 = L_COUNT4 + 1.
      when 'RSECSESSION_CL'.
        L_COUNT5 = L_COUNT5 + 1.
    endcase.
  else.
    L_ERRCOUNT = L_ERRCOUNT + 1.

  endif.

endform.                    " DELETE_FROM_TABLE

Related Content

Related Documents

Insert SAP Help links or other WIKI content

Related Notes

Insert links to any related notes/KBA that support your topic or are related

  • No labels