Skip to end of metadata
Go to start of metadata

Author: Andrea Olivieri
Supported Releases: SAP ECC 6.0
Submitted: 05 November 2011

Highlights

This report can be used to delete a large number of entries from tables SRTM_DATAX and SRTM_SUB

ABAP Source Code

*&---------------------------------------------------------------------*
*& Report  ZSDN_STRM_TABS_TRUNCATE
*&---------------------------------------------------------------------*
* Report Name: SDN: Delete entries from log data tables                *
*              SRTM_SUB and SRTM_DATAX                                 *
* Created by: Andrea Olivieri                                          *
* Company   : Techedge S.p.A                                           *
* Created on: 05.11.2011 at 00:09:55 CET                               *
*&---------------------------------------------------------------------*
REPORT  zsdn_strm_tabs_truncate LINE-SIZE 132.

DATA: gv_subrc TYPE sysubrc,
      gv_msg_text(132) TYPE c,
      gv_message_string TYPE t100-text.
DATA:
    l_text           TYPE char100,
    l_answer         TYPE char1.

CONSTANTS:
            c_tabname1 TYPE  dd02l-tabname VALUE 'SRTM_DATAX',
            c_tabname2 TYPE  dd02l-tabname VALUE 'SRTM_SUB'.

CONSTANTS: c_message_subid(1) TYPE c VALUE 'F'.
CONSTANTS: c_message_area(2) TYPE c VALUE 'D3'.

*Makro
DEFINE write_syslog.
  concatenate 'Program' sy-repid 'executed by' sy-uname
  into gv_message_string separated by space.                "#EC NOTEXT
  call function 'RSLG_WRITE_SYSLOG_ENTRY'
    exporting
      sl_message_area  = c_message_area
      sl_message_subid = c_message_subid
      pre_param_a      = gv_message_string.
END-OF-DEFINITION.

CALL FUNCTION 'POPUP_TO_CONFIRM'
  EXPORTING
    titlebar              = 'Delete LOG-POINTS data'(001)
    text_question         = 'Do you want to delete the collected LOG-POINTS data entries in tables SRTM_DATAX and SRTM_SUB ?'(002)
    text_button_1         = 'Yes'(003)
    icon_button_1         = 'ICON_DELETE'
    text_button_2         = 'No'(004)
    icon_button_2         = 'ICON_BREAKPOINT'
    default_button        = '2'
    display_cancel_button = 'X'
  IMPORTING
    answer                = l_answer.

IF l_answer <> '1'.
  RETURN.
ELSE.
  write_syslog.
ENDIF.

* delete the content from SRTM_DATAX
CALL FUNCTION 'DB_TRUNCATE_TABLE'
  EXPORTING
    tabname = c_tabname1
  IMPORTING
    subrc   = gv_subrc.
IF gv_subrc <> 0.
*   rollback the DB changes
  ROLLBACK WORK.

  MESSAGE e010(tn) WITH
                   'Error while deleting table'             "#EC NOTEXT
                   'SRTM_DATAX'                             "#EC NOTEXT
                   '->'                                     "#EC NOTEXT
                   'check in DDIC and on DB level'          "#EC NOTEXT
                   INTO gv_msg_text.
  WRITE:/ gv_msg_text.
  RETURN.
ELSE.
  CALL FUNCTION 'DB_COMMIT'.
  WRITE:/ 'All data for SRTM_DATAX was deleted'.
ENDIF.
CLEAR gv_subrc.
* delete the content from SRTM_SUB
CALL FUNCTION 'DB_TRUNCATE_TABLE'
  EXPORTING
    tabname = c_tabname2
  IMPORTING
    subrc   = gv_subrc.
IF gv_subrc <> 0.
*   rollback the DB changes
  ROLLBACK WORK.

  MESSAGE e010(tn) WITH
                   'Error while deleting table'             "#EC NOTEXT
                   'SRTM_SUB'                               "#EC NOTEXT
                   '->'                                     "#EC NOTEXT
                   'check in DDIC and on DB level'          "#EC NOTEXT
                   INTO gv_msg_text.
  WRITE:/ gv_msg_text.
  RETURN.
ELSE.
  CALL FUNCTION 'DB_COMMIT'.
  WRITE:/ 'All data for SRTM_SUB was deleted'.
ENDIF.