Child pages
  • How to find size of Infocube
Skip to end of metadata
Go to start of metadata

************************************************************************
*  Description... InfoCube Size Determination

* Author - Kenneth Murray

*  Disclaimer.... The author of this program assumes no responsibility
*                 for damages or costs incurred by use and/or estimates
*                 provided by this program!
*                 This program differs from the SAP recommended method
*                 in that it provides actuals.
*                 The SAP method is an estimate!
*                 (n + 3) * 4 bytes + ( 22 bytes * n )
*                 n = number of user dimensions
*                 m = number of key figures
************************************************************************
REPORT ZDETERMINE_INFOCUBE_SIZE NO
    STANDARD PAGE HEADING LINE-SIZE 132 LINE-COUNT 55.

INCLUDE YRPTSTD.

TABLES: DD03L,      " Table Fields
        RSDDIMET.   " Dimension Texts

TYPE-POOLS: RSDG.

TYPES: BEGIN OF T_ITABS,
   DIMENSION TYPE RSDIMENSION,       " Dimension
   TXTSH     TYPE RSTXTSH,           " Table Description
   TABLNM    TYPE RSD_S_DIME-TABLNM, " Table Name
   ROWCOUNT  TYPE I,                 " Row Count
   ROWLENGTH TYPE I,                 " Row Length
   TABLESIZE TYPE I,                 " Table Size
END OF T_ITABS.

DATA:  I_ITABS TYPE SORTED TABLE OF T_ITABS WITH UNIQUE KEY TABLNM.

DATA:  S_ITABS          TYPE T_ITABS.
DATA:  E_FACTTAB        TYPE RSD_S_CUBE-FACTTAB.
DATA:  E_COMPTAB        TYPE RSD_S_CUBE-COMPTAB.
DATA:  E_T_CUBE_DIME    TYPE RSD_T_CUBE_DIME.
DATA:  E_TABLNM         TYPE RSD_S_DIME-TABLNM.
DATA:  DIMENSION        TYPE RSD_S_CUBE_DIME.

SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK BLOCK1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_ICUBE     TYPE RSINFOCUBE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK BLOCK1.

************************************************************************
START-OF-SELECTION.
  PERFORM GET_FACT_TABLES.
  PERFORM GET_DIMENSION_TABLES.
  PERFORM GET_TABLE_DESCRIPTIONS.
  PERFORM GET_TABLE_ROW_COUNTS.
  PERFORM GET_TABLE_ROW_LENGTHS.
  PERFORM CALCULATE_INFOCUBE_SIZE.
  PERFORM OUTPUT_INFOCUBE_SIZE.
  PERFORM UPDATE_PAGE_NUMBERS.
  PERFORM OUTPUT_REPORT_SELECTIONS.

************************************************************************
TOP-OF-PAGE.
  PERFORM OUTPUT_REPORT_HEADER USING ' ' ' '.
  PERFORM OUTPUT_REPORT_COLUMNS.

************************************************************************
*&---------------------------------------------------------------------*
*&      Form  GET_FACT_TABLES
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_FACT_TABLES.
***
  CALL FUNCTION 'RSD_FACTTAB_GET_FOR_CUBE'
       EXPORTING
            I_INFOCUBE = P_ICUBE
       IMPORTING
            E_FACTTAB  = E_FACTTAB
            E_COMPTAB  = E_COMPTAB
       EXCEPTIONS
            NAME_ERROR = 1
            OTHERS     = 2.

  IF SY-SUBRC = 0.
    S_ITABS-TABLNM = E_FACTTAB.
    S_ITABS-TXTSH  = 'F Fact Table'.
    INSERT S_ITABS INTO TABLE I_ITABS.

    S_ITABS-TABLNM = E_COMPTAB.
    S_ITABS-TXTSH  = 'E Fact Table'.

    INSERT S_ITABS INTO TABLE I_ITABS.
  ENDIF.
***
ENDFORM.                    " GET_FACT_TABLES

*&---------------------------------------------------------------------*
*&      Form  GET_DIMENSION_TABLES
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_DIMENSION_TABLES.
***
  PERFORM GET_DIMENSION_NAMES.

  LOOP AT E_T_CUBE_DIME INTO DIMENSION.

    CALL FUNCTION 'RSD_TABLNM_GET_FOR_DIME'
         EXPORTING
              I_DIMENSION = DIMENSION-DIMENSION
         IMPORTING
              E_TABLNM    = E_TABLNM
         EXCEPTIONS
              NAME_ERROR  = 1
              OTHERS      = 2.

    IF SY-SUBRC = 0.
      S_ITABS-DIMENSION = DIMENSION-DIMENSION.
      S_ITABS-TABLNM = E_TABLNM.
      INSERT S_ITABS INTO TABLE I_ITABS.
    ENDIF.

  ENDLOOP.
***
ENDFORM.                    " GET_DIMENSION_TABLES

*&---------------------------------------------------------------------*
*&      Form  GET_DIMENSION_NAMES
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_DIMENSION_NAMES.
***
  CALL FUNCTION 'RSD_CUBE_GET'
       EXPORTING
            I_INFOCUBE         = P_ICUBE
       IMPORTING
            E_T_CUBE_DIME      = E_T_CUBE_DIME
       EXCEPTIONS
            INFOCUBE_NOT_FOUND = 1
            ILLEGAL_INPUT      = 2
            OTHERS             = 3.

  IF SY-SUBRC <> 0.
  ENDIF.
***
ENDFORM.                    " GET_DIMENSION_NAMES

*&---------------------------------------------------------------------*
*&      Form  GET_TABLE_ROW_COUNTS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_TABLE_ROW_COUNTS.
***
  LOOP AT I_ITABS INTO S_ITABS.
    SELECT COUNT(star) INTO S_ITABS-ROWCOUNT FROM (S_ITABS-TABLNM).
    MODIFY TABLE I_ITABS FROM S_ITABS.
  ENDLOOP.
***
ENDFORM.                    " GET_TABLE_ROW_COUNTS

*&---------------------------------------------------------------------*
*&      Form  GET_TABLE_ROW_LENGTHS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_TABLE_ROW_LENGTHS.
***
  LOOP AT I_ITABS INTO S_ITABS.

    SELECT INTLEN INTO DD03L-INTLEN FROM DD03L
        WHERE TABNAME = S_ITABS-TABLNM.
      S_ITABS-ROWLENGTH = S_ITABS-ROWLENGTH + DD03L-INTLEN.
    ENDSELECT.
    MODIFY TABLE I_ITABS FROM S_ITABS.
  ENDLOOP.
***
ENDFORM.                    " GET_TABLE_ROW_LENGTHS

*&---------------------------------------------------------------------*
*&      Form  CALCULATE_INFOCUBE_SIZE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM CALCULATE_INFOCUBE_SIZE.
***
  LOOP AT I_ITABS INTO S_ITABS.
    S_ITABS-TABLESIZE =  S_ITABS-ROWLENGTH * S_ITABS-ROWCOUNT.
    MODIFY TABLE I_ITABS FROM S_ITABS.
  ENDLOOP.
***
ENDFORM.                    " CALCULATE_INFOCUBE_SIZE

*&---------------------------------------------------------------------*
*&      Form  OUTPUT_INFOCUBE_SIZE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM OUTPUT_INFOCUBE_SIZE.
***
  DATA: W_TABLESIZE TYPE I.
  DATA: W_KILOBYTES TYPE P DECIMALS 2.
  DATA: W_MEGABYTES TYPE P DECIMALS 2.
  DATA: W_ITABCOUNT TYPE I VALUE 2000.

  LOOP AT I_ITABS INTO S_ITABS.
    S_ITABS-ROWCOUNT = 1.
    S_ITABS-TABLESIZE = S_ITABS-ROWCOUNT * S_ITABS-ROWLENGTH.

    WRITE:/ S_ITABS-TABLNM     UNDER 'Table',
            S_ITABS-TXTSH      UNDER 'Description',
            S_ITABS-ROWCOUNT   UNDER 'Row Count',
            S_ITABS-ROWLENGTH  UNDER 'Row Length',
            S_ITABS-TABLESIZE  UNDER 'Table Size'.
   W_TABLESIZE = W_TABLESIZE + ( S_ITABS-ROWCOUNT * S_ITABS-ROWLENGTH ).
  ENDLOOP.

  W_KILOBYTES = W_TABLESIZE / 1024.
  W_MEGABYTES = W_KILOBYTES / 1000.

  SKIP.
  WRITE:/ 'Total ***' UNDER 'Row Length',
          W_TABLESIZE UNDER 'Table Size',
          W_MEGABYTES, 'Megabytes'.

***
NEW-PAGE.

  LOOP AT I_ITABS INTO S_ITABS.
    WRITE:/ S_ITABS-TABLNM     UNDER 'Table',
            S_ITABS-TXTSH      UNDER 'Description',
            S_ITABS-ROWCOUNT   UNDER 'Row Count',
            S_ITABS-ROWLENGTH  UNDER 'Row Length',
            S_ITABS-TABLESIZE  UNDER 'Table Size'.
    W_TABLESIZE = W_TABLESIZE + S_ITABS-TABLESIZE.
  ENDLOOP.

  W_KILOBYTES = W_TABLESIZE / 1024.
  W_MEGABYTES = W_KILOBYTES / 1000.

  SKIP.
  WRITE:/ 'Total ***' UNDER 'Row Length',
          W_TABLESIZE UNDER 'Table Size',
          W_MEGABYTES, 'Megabytes'.
***
ENDFORM.                    " OUTPUT_INFOCUBE_SIZE

*&---------------------------------------------------------------------*
*&      Form  output_REPORT_COLUMNS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM OUTPUT_REPORT_COLUMNS.
***
  WRITE: /1  'Table'       COLOR COL_HEADING,
          35 'Description' COLOR COL_HEADING,
          55 'Row Count'   COLOR COL_HEADING,
          70 'Row Length'  COLOR COL_HEADING,
          85 'Table Size'  COLOR COL_HEADING.
***
ENDFORM.                    " output_REPORT_COLUMNS

*&---------------------------------------------------------------------*
*&      Form  GET_TABLE_DESCRIPTIONS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_TABLE_DESCRIPTIONS.
***
  DATA: DIMENSION TYPE RSDIMENSION.

  LOOP AT I_ITABS INTO S_ITABS.
    SELECT SINGLE TXTSH INTO S_ITABS-TXTSH FROM RSDDIMET
        WHERE LANGU = SY-LANGU
          AND INFOCUBE = P_ICUBE
          AND OBJVERS  = 'A'
          AND DIMENSION = S_ITABS-DIMENSION.

    MODIFY I_ITABS FROM S_ITABS.
  ENDLOOP.
***
ENDFORM.                    " GET_TABLE_DESCRIPTIONS

2 Comments

  1. Former Member

    INCLUDE YRPTSTD is not defined here .. please include it and also some FORMs are undefined

  2. Unknown User (100uwnn8a)

    Thanks for code .. But witout Include and few forms.. This is useless for all