Cube的效果如何,需要通过纬度表的大小来判断,系统自带有一只程序去分析,但是每次会把系统所有的Cube都分析一遍,结果也不好找。 所以稍微修改了一下。
程序前提: Cube 执行一次“数据库统计”, 在Cube 的管理页面,有一个性能标签页,在那里可以执行此操作。
REPORT ZR_INFOCUBE_DESIGNS
.
******************************************************************************
*todo: analyse the dimension table , compare the result to fact table
*modi: Robin Lei
*date: 2013.7.18
*******************************************************************************
TYPE-POOLS : RSD , RSDU .
DATA : L_T_CUBE TYPE RSD_T_CUBE ,
L_S_CUBE TYPE RSD_S_CUBE ,
L_FACTROWS TYPE I ,
L_S_TABLSIZE TYPE RSDU_S_TABLSIZE ,
L_T_TABLSIZE TYPE RSDU_T_TABLSIZE ,
L_DENSITY TYPE F ,
L_PDENSITY TYPE P DECIMALS 1 ,
L_COUNTER TYPE I ,
L_ODD TYPE I .
PARAMETERS :L_CUBE TYPE RSINFOCUBE .
* get list of all active infocubes in the system
CALL FUNCTION 'RSD_CUBE_MULTI_GET_ONLY_DB'
EXPORTING
I_READ_ALL = RS_C_TRUE
* I_T_INFOCUBE =
I_OBJVERS = RS_C_OBJVERS -ACTIVE
* I_CUBETYPE = 'B'
* I_T_CUBETYPE =
* I_WITH_ATR_NAV = RS_C_FALSE
IMPORTING
E_T_CUBE = L_T_CUBE
* E_T_CUBE_IOBJ =
* E_T_DIME_IOBJ =
* E_T_IC_VAL_IOBJ =
EXCEPTIONS
ILLEGAL_INPUT = 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 .
* loop over the cubes and get information
L_COUNTER = 0 .
LOOP AT L_T_CUBE INTO L_S_CUBE WHERE INFOCUBE = L_CUBE .
* get cube layout information
CALL FUNCTION 'RSDU_INFOCUBE_TABLE_SIZES'
EXPORTING
I_INFOCUBE = L_S_CUBE -INFOCUBE
I_CHECK = RS_C_TRUE
IMPORTING
E_FACTROWS = L_FACTROWS
E_T_TABLSIZE = L_T_TABLSIZE
E_DENSITY = L_DENSITY .
* give details only for non-empty cubes
IF L_FACTROWS = 0 . CONTINUE . ENDIF .
* count non-empty cubes
L_COUNTER = L_COUNTER + 1 .
* set format
FORMAT COLOR COL_BACKGROUND INVERSE ON .
* print cube infos
L_PDENSITY = L_DENSITY .
WRITE : AT / L_S_CUBE -INFOCUBE ,
AT 20 'rows:' , L_FACTROWS ,
AT 40 'density:' , L_PDENSITY , '%' .
* print cube table infos
LOOP AT L_T_TABLSIZE INTO L_S_TABLSIZE .
* swap formats
L_ODD = L_COUNTER MOD 2 .
IF L_ODD = 1 .
FORMAT COLOR COL_BACKGROUND INTENSIFIED OFF INVERSE OFF .
ELSE .
FORMAT COLOR COL_BACKGROUND INTENSIFIED ON INVERSE OFF .
ENDIF .
* write ...
IF L_S_TABLSIZE -SIZE_CHECK <> RSDU_C_CHECK -GREEN .
FORMAT COLOR COL_NEGATIVE INTENSIFIED OFF INVERSE ON .
ENDIF .
WRITE : AT / L_S_CUBE -INFOCUBE ,
AT 20 L_S_TABLSIZE -TABLNM ,
AT 40 'rows:' , L_S_TABLSIZE - ROWS ,
AT 60 'ratio:' , L_S_TABLSIZE -PERCENT , '%' .
ENDLOOP .
ENDLOOP .
IF SY -SUBRC NE 0 .
WRITE : L_CUBE , 'NOT EXIST!' .
ENDIF .
******************************************************************************
*todo: analyse the dimension table , compare the result to fact table
*modi: Robin Lei
*date: 2013.7.18
*******************************************************************************
TYPE-POOLS : RSD , RSDU .
DATA : L_T_CUBE TYPE RSD_T_CUBE ,
L_S_CUBE TYPE RSD_S_CUBE ,
L_FACTROWS TYPE I ,
L_S_TABLSIZE TYPE RSDU_S_TABLSIZE ,
L_T_TABLSIZE TYPE RSDU_T_TABLSIZE ,
L_DENSITY TYPE F ,
L_PDENSITY TYPE P DECIMALS 1 ,
L_COUNTER TYPE I ,
L_ODD TYPE I .
PARAMETERS :L_CUBE TYPE RSINFOCUBE .
* get list of all active infocubes in the system
CALL FUNCTION 'RSD_CUBE_MULTI_GET_ONLY_DB'
EXPORTING
I_READ_ALL = RS_C_TRUE
* I_T_INFOCUBE =
I_OBJVERS = RS_C_OBJVERS -ACTIVE
* I_CUBETYPE = 'B'
* I_T_CUBETYPE =
* I_WITH_ATR_NAV = RS_C_FALSE
IMPORTING
E_T_CUBE = L_T_CUBE
* E_T_CUBE_IOBJ =
* E_T_DIME_IOBJ =
* E_T_IC_VAL_IOBJ =
EXCEPTIONS
ILLEGAL_INPUT = 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 .
* loop over the cubes and get information
L_COUNTER = 0 .
LOOP AT L_T_CUBE INTO L_S_CUBE WHERE INFOCUBE = L_CUBE .
* get cube layout information
CALL FUNCTION 'RSDU_INFOCUBE_TABLE_SIZES'
EXPORTING
I_INFOCUBE = L_S_CUBE -INFOCUBE
I_CHECK = RS_C_TRUE
IMPORTING
E_FACTROWS = L_FACTROWS
E_T_TABLSIZE = L_T_TABLSIZE
E_DENSITY = L_DENSITY .
* give details only for non-empty cubes
IF L_FACTROWS = 0 . CONTINUE . ENDIF .
* count non-empty cubes
L_COUNTER = L_COUNTER + 1 .
* set format
FORMAT COLOR COL_BACKGROUND INVERSE ON .
* print cube infos
L_PDENSITY = L_DENSITY .
WRITE : AT / L_S_CUBE -INFOCUBE ,
AT 20 'rows:' , L_FACTROWS ,
AT 40 'density:' , L_PDENSITY , '%' .
* print cube table infos
LOOP AT L_T_TABLSIZE INTO L_S_TABLSIZE .
* swap formats
L_ODD = L_COUNTER MOD 2 .
IF L_ODD = 1 .
FORMAT COLOR COL_BACKGROUND INTENSIFIED OFF INVERSE OFF .
ELSE .
FORMAT COLOR COL_BACKGROUND INTENSIFIED ON INVERSE OFF .
ENDIF .
* write ...
IF L_S_TABLSIZE -SIZE_CHECK <> RSDU_C_CHECK -GREEN .
FORMAT COLOR COL_NEGATIVE INTENSIFIED OFF INVERSE ON .
ENDIF .
WRITE : AT / L_S_CUBE -INFOCUBE ,
AT 20 L_S_TABLSIZE -TABLNM ,
AT 40 'rows:' , L_S_TABLSIZE - ROWS ,
AT 60 'ratio:' , L_S_TABLSIZE -PERCENT , '%' .
ENDLOOP .
ENDLOOP .
IF SY -SUBRC NE 0 .
WRITE : L_CUBE , 'NOT EXIST!' .
ENDIF .
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/554557/viewspace-766643/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/554557/viewspace-766643/