Tuesday, June 2, 2015

How to Delete Unused Dimension Values from Info Cube in Process Chains

As a  BW developer you may need to remove some characteristics from cube’s dimension. This is needed in case of you do remodel your cube. You may even need to remove whole dimension(s) in some cases. 

OR 

In some cases if you want to restrict the list of values in Bex variable selections, to only the values in the cube.

To achieve this we created a simple ABAP program which uses the standard SAP function module with input selection screen. Using the input selection screen we can select the info cube(s) for which we want to delete the unused dimension ID's and create a variant so that we can scheudule this via process to keep our info cubes tidy.



*&---------------------------------------------------------------------*
*& Report  ZBW_DELETE_UNUSED_DIMENSIONS
*&
*&---------------------------------------------------------------------*
*& This Program is used in BW Process Chains to Delete any unused DIM ID's
*& in selected info cubes.
*& Note: Line Item dimensions are not deleted using this FM.
*&       ABAP Process Type to be used in a process chains.
*&       Poor performance will be noted when deleting DIM ID's from a large cube.
*&
*&
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*

REPORT  ZBW_DELETE_UNUSED_DIMENSIONS.

PARAMETERS S_CUBE  TYPE RSINFOCUBE      " Info Cube Selection
    MATCHCODE OBJECT H_UPCBW_INFOCUBE   " F4 Search
    OBLIGATORY.                         " Mandatory Selection

* Function module to delete unused DIM ID's.
* If a cube has millions of records then the performance of this FM
* is poor. When deleting DIM ID's the cube will be in locked state.

CALL FUNCTION 'RSDRD_DIM_REMOVE_UNUSED'
  EXPORTING
    I_INFOCUBE              = S_CUBE
*   I_T_DIME                =
   I_CHECK_ONLY            = ' '
   I_COMMIT_AFTER_N        = 500000
   I_REPORT_ONLY_N         = 50
* IMPORTING
*   E_REPAIR_POSSIBLE       =
* CHANGING
*   C_T_MSG                 =
 EXCEPTIONS
   X_MESSAGE               = 1
   OTHERS                  = 2
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

No comments: