Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Description
/The report program computes the size of one or more archive objects by finding the size of individual tables that comprise the archive object. The output will be displayed on the screen and can also be downloaded to the presentation server./

Error rendering macro 'code': Invalid value specified for parameter 'lang'
REPORT Z_COMPUTE_ARCHIVE_OBJECT_SIZE.
TABLES : ARCH_OBJ.
TYPE-POOLS : ADK .
*---> data declaration
DATA : BEGIN OF I_TAB_AOBJ OCCURS 0,
OBJECT LIKE ARCH_OBJ-OBJECT.
DATA : END OF I_TAB_AOBJ.
DATA : BEGIN OF I_TAB_YES_DEL OCCURS 0,
OBJECT LIKE ARCH_OBJ-OBJECT,
TABNAME LIKE DD02V-TABNAME,
TEXT LIKE DD02V-DDTEXT.
DATA : END OF I_TAB_YES_DEL.
DATA: BEGIN OF I_DBSTAT OCCURS 0.
        INCLUDE STRUCTURE DBSTATAM.
DATA: END OF I_DBSTAT.
DATA: BEGIN OF I_OUTPUT OCCURS 0,
OBJECT LIKE ARCH_OBJ-OBJECT,
TNAME LIKE I_DBSTAT-TNAME,
NROWS LIKE I_DBSTAT-NROWS,
OCCTB LIKE I_DBSTAT-OCCTB,
OCCIX LIKE I_DBSTAT-OCCIX.
DATA: END OF I_OUTPUT.
DATA: I_OBJECT_TABLES TYPE ADK_CCMS_TABLE OCCURS 0.
DATA: WA_OBJECT_TABLES TYPE ADK_CCMS_TABLE.
DATA: V_ARCOBJ LIKE ARCH_OBJ-OBJECT.
*---> selection criteria - archive object
SELECT-OPTIONS A_OBJECT FOR ARCH_OBJ-OBJECT.
*---> Output filename
PARAMETERS: FILENAME TYPE STRING.
*---> check the input
SELECT OBJECT INTO I_TAB_AOBJ FROM ARCH_OBJ WHERE OBJECT IN A_OBJECT.
  APPEND I_TAB_AOBJ.
ENDSELECT.
*---> get the list of tables that comprise the arhive object
IF NOT I_TAB_AOBJ[] IS INITIAL.
  REFRESH I_OBJECT_TABLES.
  LOOP AT I_TAB_AOBJ.
    CALL FUNCTION 'ADK_CCMS_GET_TABLES'
    EXPORTING
    OBJECT = I_TAB_AOBJ-OBJECT
    DELETE_TABLES_ONLY = ''
    TABLES
    OBJECT_TABLES = I_OBJECT_TABLES
* EXCEPTIONS
* OBJECT_NOT_FOUND = 1
* OTHERS = 2
    .
    LOOP AT I_OBJECT_TABLES INTO WA_OBJECT_TABLES.
      I_TAB_YES_DEL-OBJECT = I_TAB_AOBJ-OBJECT .
      I_TAB_YES_DEL-TABNAME = WA_OBJECT_TABLES-TABNAME.
      I_TAB_YES_DEL-TEXT = WA_OBJECT_TABLES-TEXT.
      APPEND I_TAB_YES_DEL.
    ENDLOOP.
    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.
ENDIF.
*--> find size of each table that comprise the archive object
LOOP AT I_TAB_YES_DEL.
  REFRESH I_DBSTAT.
  MOVE I_TAB_YES_DEL-OBJECT TO V_ARCOBJ.
  MOVE I_TAB_YES_DEL-TABNAME TO I_DBSTAT-TNAME.
  APPEND I_DBSTAT.
  CALL FUNCTION 'DB_TABLE_DATA_READ' " online lesen
  TABLES
  DBSTAT = I_DBSTAT
  EXCEPTIONS
  NO_DATA_FOUND = 2 " online nicht gefunden
  OTHERS = 3.
  I_OUTPUT-OBJECT = V_ARCOBJ.
  LOOP AT I_DBSTAT.
    I_OUTPUT-TNAME = I_DBSTAT-TNAME.
    I_OUTPUT-NROWS = I_DBSTAT-NROWS.
    I_OUTPUT-OCCTB = I_DBSTAT-OCCTB.
    I_OUTPUT-OCCIX = I_DBSTAT-OCCIX.
    APPEND I_OUTPUT.
  ENDLOOP.
ENDLOOP.
*---> write output to screen
WRITE : 'OBJECT ', '|', 'TABLE NAME ', '|',
'Number of records ' , '|' , 'Table Size(KB)' , '|' , 'Indexes size (KB)'.
LOOP AT I_OUTPUT.
  WRITE : / I_OUTPUT-OBJECT, '|', I_OUTPUT-TNAME, '|',
  I_OUTPUT-NROWS , '|' , I_OUTPUT-OCCTB , '|' , I_OUTPUT-OCCIX.
ENDLOOP.
*---> write output to file
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
  EXPORTING
    FILENAME         = FILENAME
    FILETYPE         = 'DAT'
  CHANGING
    DATA_TAB         = I_OUTPUT[]
  EXCEPTIONS
    FILE_WRITE_ERROR = 1
    NO_BATCH         = 2.
  • No labels