IT/SAP

Delete RSECADMIN

SAP_BASIS 2016. 5. 20. 13:20

REPORT ZRSEC_PROT_DEL.
TABLES: rseclog_cl.
DATA: l_rt_timestamp     TYPE RANGE OF rsddtimestmp,
      l_t_rseclog_cl TYPE TABLE OF rseclog_cl,
      l_s_rseclog_cl TYPE rseclog_cl,
      l_pid        TYPE sysuuid_c,
      l_t_pid      TYPE rsec_t_pid.
"SELECTION-SCREEN BEGIN.
SELECT-OPTIONS s_tmstmp FOR rseclog_cl-timestmp.
INSERT LINES OF s_tmstmp INTO  TABLE l_rt_timestamp.
SELECT * FROM rseclog_cl INTO CORRESPONDING FIELDS OF TABLE l_t_rseclog_cl WHERE timestmp IN l_rt_timestamp.
IF l_t_rseclog_cl IS INITIAL.
   MESSAGE s306(rsec).
EXIT.
ENDIF.
LOOP AT l_t_rseclog_cl INTO l_s_rseclog_cl.
  l_pid = l_s_rseclog_cl-sessionid.
  INSERT l_pid INTO TABLE l_t_pid.
ENDLOOP.
CLEAR: l_t_rseclog_cl.
SELECT * FROM rseclog_cl INTO TABLE l_t_rseclog_cl
  FOR ALL ENTRIES IN l_t_pid
   WHERE sessionid = l_t_pid-table_line.
IF l_t_rseclog_cl IS INITIAL.
  MESSAGE s306(rsec).
  EXIT.
ENDIF.
CLEAR l_pid.
LOOP AT l_t_rseclog_cl INTO l_s_rseclog_cl.
  l_pid = l_s_rseclog_cl.
  DELETE FROM rseclog    WHERE pid       = l_pid.
  DELETE FROM rseclog_cl WHERE sessionid = l_pid.
  CLEAR  l_pid.
ENDLOOP.
CALL FUNCTION 'DB_COMMIT'.