I use the issue in this blog to demonstrate the usage of this small repository parse tool:
We need to know under which enhancement set the component usage “ZCUSTOM” is added to UI component BT116H_SRVO.
This customizing activity could allow us to compare the runtime repositry between the original UI component and the enhanced one:
However, if there are too many enhancement sets in the system, it could be very inefficient for manual comparison.
Fortunately the comparison could be done by code below.
The report is quite simple:
1. in line 9, get all enhancement sets list under which the UI component is enhanced.
2. get the enhanced BSP application name and page name in line 11 and 12, then get the component usage information for each enhanced BSP application via repository tool, then filter it by usage name “ZCUSTOM”.
REPORT zbsp. CONSTANTS: cv_host TYPE o2applname VALUE 'BT116H_SRVO'. DATA: lt_enh_sets TYPE bsp_dlct_ehset, ls_enh_set LIKE LINE OF lt_enh_sets, lt_extension TYPE STANDARD TABLE OF bspwd_comp_ext, ls_extension LIKE LINE OF lt_extension, lt_usages TYPE bsp_wd_cmp_usage_descr_tab, ls_usage LIKE LINE OF lt_usages. lt_enh_sets = cl_bsp_dlc_config_util=>get_eh_sets_of_comp( iv_comp_name = cv_host ). CHECK lt_enh_sets IS NOT INITIAL. SELECT * INTO TABLE lt_extension FROM bspwd_comp_ext FOR ALL ENTRIES IN lt_enh_sets WHERE enhancement_set = lt_enh_sets-enhancement_set AND comp_name = cv_host. LOOP AT lt_enh_sets INTO ls_enh_set. READ TABLE lt_extension INTO ls_extension WITH KEY enhancement_set = ls_enh_set-enhancement_set comp_name = cv_host. IF sy-subrc = 0. CLEAR: lt_usages. CALL METHOD zcl_view_repo_tool=>get_repo_metadata( EXPORTING iv_comp_name = ls_extension-bsp_appl iv_page_name = ls_extension-rt_rep_page IMPORTING et_usages = lt_usages ). READ TABLE lt_usages WITH KEY usage_name = 'ZCUSTOM' INTO ls_usage. IF sy-subrc = 0. WRITE: / 'EnhancementSet: ', ls_enh_set-enhancement_set, ' defines component usage to component: ', ls_usage-child_cmp_type. ENDIF. ENDIF. ENDLOOP.
The small parse tool zcl_view_repo_tool just parse the repository xml from database table and convert it to two internal tables which contains the view information and component usage information. Its source code could be found in attachment.
We can compare the report execution result and the manual check via customizing activity: they are exactly the same.