*&---------------------------------------------------------------------* *& Report : /EUTIN/FIND_FIELD_DTEL_DOMA *& Title : Where-used-list of Fields, DTEL and/or DOMA in TABL *& Developer : Michael Eutin - 20190905 1612 *& Package : /EUTIN/TOOLS *& Description: *& Find all tables of type requested table class, like transparent table, *& pooled table and cluster table, where specific field names, data *& elements and or domain names are used. *&---------------------------------------------------------------------* *& CHANGE HISTORY *&---------------------------------------------------------------------* *& Date Description *&---------------------------------------------------------------------* *& *& *& *& *&---------------------------------------------------------------------* REPORT /eutin/find_field_dtel_doma. *---------------------------------------------------------------------- *--- global data declarations *---------------------------------------------------------------------- CONSTANTS: con_title TYPE sytitle VALUE 'Where-used-list of Fields, DTEL and/or DOMA in TABL', con_tabname TYPE dd02l-tabname VALUE '##############################', con_tabclass TYPE dd02l-tabclass VALUE '########', con_fieldname TYPE dd03l-fieldname VALUE '##############################', con_rollname TYPE dd04l-rollname VALUE '##############################', con_domname TYPE dd01l-domname VALUE '##############################', con_inttype TYPE dd03l-inttype VALUE '#', con_intlen TYPE dd03l-intlen VALUE 0, con_datatype TYPE dd03l-datatype VALUE '####', con_leng TYPE dd03l-leng VALUE 0. *---------------------------------------------------------------------- *--- selection screen 1000 *---------------------------------------------------------------------- SELECTION-SCREEN BEGIN OF BLOCK sel WITH FRAME TITLE sel. SELECT-OPTIONS: s_tabnam FOR con_tabname, s_tabcla FOR con_tabclass, s_fieldn FOR con_fieldname, s_rollna FOR con_rollname, s_domnam FOR con_domname, s_inttyp FOR con_inttype, s_intlen FOR con_intlen, s_dataty FOR con_datatype, s_leng FOR con_leng. PARAMETERS: p_uname AS CHECKBOX DEFAULT space. SELECTION-SCREEN END OF BLOCK sel. *---------------------------------------------------------------------- *--- Event INITIALIZATION *---------------------------------------------------------------------- INITIALIZATION. PERFORM init. *---------------------------------------------------------------------- *--- Event START-OF-SELECTION *---------------------------------------------------------------------- START-OF-SELECTION. PERFORM main. *&---------------------------------------------------------------------* *& Form INIT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* FORM init. DATA: ls_tabname LIKE LINE OF s_tabnam, ls_tabclass LIKE LINE OF s_tabcla, ls_rollname LIKE LINE OF s_rollna. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *--- define texts for selection screen 1000 sy-title = con_title. sel = 'Selections'. %_s_tabnam_%_app_%-text = 'Table Name'. %_s_tabcla_%_app_%-text = 'Table Class'. %_s_fieldn_%_app_%-text = 'Field Name'. %_s_rollna_%_app_%-text = 'Data Element'. %_s_domnam_%_app_%-text = 'Domain Name'. %_s_inttyp_%_app_%-text = 'ABAP data type (C,D,N,...)'. %_s_intlen_%_app_%-text = 'Internal Length in Bytes'. %_s_dataty_%_app_%-text = 'Data Type in ABAP Dictionary'. %_s_leng_%_app_%-text = 'Length (No. of Characters)'. %_p_uname_%_app_%-text = 'User: Creator or Last Changer'. *--- default selection screen parameters CLEAR: s_tabnam[], s_tabcla[], s_rollna[]. ls_tabname = 'ECP'. ls_tabname-low = '/EUTIN/*'. INSERT ls_tabname INTO TABLE s_tabnam. IF sy-subrc NE 0. MESSAGE 'INSERT into S_TABNAM failed!' TYPE 'E'. ENDIF. ls_tabclass = 'IEQ'. ls_tabclass-low = 'TRANSP'. "Transparent table INSERT ls_tabclass INTO TABLE s_tabcla. IF sy-subrc EQ 0. ls_tabclass-low = 'CLUSTER'. "Cluster table INSERT ls_tabclass INTO TABLE s_tabcla. IF sy-subrc EQ 0. ls_tabclass-low = 'POOL'. "Pooled table INSERT ls_tabclass INTO TABLE s_tabcla. ENDIF. ENDIF. IF sy-subrc NE 0. MESSAGE 'INSERT into S_TABCLA failed!' TYPE 'E'. ENDIF. ls_rollname = 'ICP'. ls_rollname-low = '/EUTIN/*'. INSERT ls_rollname INTO TABLE s_rollna. IF sy-subrc NE 0. MESSAGE 'INSERT into S_ROLLNA failed!' TYPE 'E'. ENDIF. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ENDFORM. *&---------------------------------------------------------------------* *& Form MAIN *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* FORM main. DATA: lv_where TYPE string, lv_user_name TYPE usr02-bname. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sy-title = con_title. SELECT a~tabname, c~ddtext, b~fieldname, b~position, b~rollname, b~domname, b~inttype, b~intlen, b~datatype, b~leng, b~decimals INTO TABLE @DATA(lt_output) FROM dd02l AS a INNER JOIN dd03l AS b ON b~tabname EQ a~tabname AND b~as4local EQ a~as4local AND b~as4vers EQ a~as4vers LEFT OUTER JOIN dd02t AS c ON c~tabname EQ a~tabname AND c~ddlanguage EQ @sy-langu AND c~as4local EQ a~as4local AND c~as4vers EQ a~as4vers WHERE a~tabname IN @s_tabnam AND a~as4local EQ 'A' AND a~as4vers EQ '0000' AND a~tabclass IN @s_tabcla AND b~fieldname IN @s_fieldn AND b~rollname IN @s_rollna AND b~domname IN @s_domnam AND ( b~inttype IN @s_inttyp AND b~intlen IN @s_intlen ) AND ( b~datatype IN @s_dataty AND b~leng IN @s_leng ). IF sy-subrc NE 0 OR lt_output[] IS INITIAL. MESSAGE 'Nothing found.' TYPE 'S' DISPLAY LIKE 'I'. RETURN. ENDIF. SORT lt_output ASCENDING BY tabname position. IF p_uname EQ 'X' AND 'CNAM' IN s_rollna AND 'UNAM' IN s_rollna. DELETE lt_output WHERE NOT ( rollname EQ 'CNAM' OR rollname EQ 'UNAM' ). LOOP AT lt_output ASSIGNING FIELD-SYMBOL(). DATA(lv_tabix) = sy-tabix. CLEAR: lv_where, lv_user_name. lv_where = |{ -fieldname } = '{ sy-uname }'|. TRY. SELECT SINGLE (-fieldname) INTO lv_user_name FROM (-tabname) WHERE (lv_where). IF sy-subrc NE 0. DELETE lt_output INDEX lv_tabix. CONTINUE. ENDIF. CATCH cx_root INTO DATA(lx_root). DATA(lv_message) = lx_root->if_message~get_text( ). IF lv_message IS NOT INITIAL. MESSAGE lv_message TYPE 'I' DISPLAY LIKE 'E'. ENDIF. MESSAGE 'Dynamic SELECT statement failed' TYPE 'S' DISPLAY LIKE 'E'. RETURN. ENDTRY. ENDLOOP. ENDIF. PERFORM display_alv USING lt_output[]. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ENDFORM. *&---------------------------------------------------------------------* *& Form DISPLAY_ALV *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->IT_ANY_TABLE[] text *----------------------------------------------------------------------* FORM display_alv USING it_any_table TYPE ANY TABLE. DATA: lr_alv_table TYPE REF TO cl_salv_table, lr_functions_list TYPE REF TO cl_salv_functions_list, lr_columns_table TYPE REF TO cl_salv_columns_table, lr_column_table TYPE REF TO cl_salv_column_table, lr_display_settings TYPE REF TO cl_salv_display_settings, lr_header_info TYPE REF TO cl_salv_form_header_info, lx_salv_msg TYPE REF TO cx_salv_msg, lx_salv_not_found TYPE REF TO cx_salv_not_found, lx_salv_data_error TYPE REF TO cx_salv_data_error, lx_salv_existing TYPE REF TO cx_salv_existing, lx_root TYPE REF TO cx_root, lv_error TYPE string, lv_counts TYPE i, lv_header_count TYPE c LENGTH 20, lv_header_text TYPE string. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IF it_any_table[] IS INITIAL. RETURN. ENDIF. TRY. *--- create ALV table cl_salv_table=>factory( IMPORTING r_salv_table = lr_alv_table CHANGING t_table = it_any_table[] ). *--- activate all standard functions lr_functions_list = lr_alv_table->get_functions( ). lr_functions_list->set_all( if_salv_c_bool_sap=>true ). *--- set optimized column size lr_columns_table = lr_alv_table->get_columns( ). lr_columns_table->set_optimize( if_salv_c_bool_sap=>true ). *--- set zebra layout lr_display_settings = lr_alv_table->get_display_settings( ). lr_display_settings->set_striped_pattern( if_salv_c_bool_sap=>true ). **--- set column headers * DEFINE set_column_header. * lr_column_table ?= lr_columns_table->get_column( &1 ). * lr_column_table->set_short_text( &2 ). * lr_column_table->set_medium_text( &2 ). * lr_column_table->set_long_text( &2 ). * END-OF-DEFINITION. * set_column_header 'FUNCNAME' 'FUNCNAME'. * set_column_header 'MESTYPE' 'MESTYPE'. *--- set title lr_display_settings->set_list_header( 'Where-Used-List of Field Names, Data Elements and/or Domains' ). *--- set header and display number of displayed entries DESCRIBE TABLE it_any_table LINES lv_counts. WRITE lv_counts TO lv_header_count LEFT-JUSTIFIED. CONCATENATE 'Number of entries in result list:' lv_header_count INTO lv_header_text SEPARATED BY space. CREATE OBJECT lr_header_info EXPORTING text = lv_header_text. lr_alv_table->set_top_of_list( EXPORTING value = lr_header_info ). *--- display table lr_alv_table->display( ). *--- error handling CATCH cx_salv_msg INTO lx_salv_msg. CLEAR lv_error. lv_error = lx_salv_msg->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. CATCH cx_salv_not_found INTO lx_salv_not_found. CLEAR lv_error. lv_error = lx_salv_not_found->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. CATCH cx_salv_data_error INTO lx_salv_data_error. CLEAR lv_error. lv_error = lx_salv_data_error->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. CATCH cx_salv_existing INTO lx_salv_existing. CLEAR lv_error. lv_error = lx_salv_existing->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. CATCH cx_root INTO lx_root. "pragma or pseudo comment CATCH_ALL: okay, one to catch them all! *--- error tolerant mode: do not cause catchable runtime errors! CLEAR lv_error. lv_error = lx_root->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. ENDTRY. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ENDFORM. " DISPLAY_ALV *--- The End!