*&---------------------------------------------------------------------* *& Report : /EUTIN/AUTH_OBJECTS_OF_ROLES *& Title : Display Authorization Objects of Roles *& Developer : EUTINM - 20190521 16.26 *& Development Class : /EUTIN/TOOLS *& Description : *& Display all authorization objects of requested roles *& *&---------------------------------------------------------------------* *& CHANGE HISTORY *&---------------------------------------------------------------------* *& Date Description *&---------------------------------------------------------------------* *& *& *& *& *&---------------------------------------------------------------------* REPORT /eutin/auth_objects_of_roles LINE-SIZE 255. *---------------------------------------------------------------------- *--- global data declarations *---------------------------------------------------------------------- CONSTANTS: con_agr_name TYPE agr_define-agr_name VALUE '###########', con_title TYPE sytitle VALUE 'Display Authorization Objects of Roles'. *---------------------------------------------------------------------- *--- selection screen 1000 *---------------------------------------------------------------------- SELECTION-SCREEN BEGIN OF BLOCK sel WITH FRAME TITLE sel. SELECT-OPTIONS: s_agrnam FOR con_agr_name OBLIGATORY. SELECTION-SCREEN END OF BLOCK sel. SELECTION-SCREEN BEGIN OF BLOCK out WITH FRAME TITLE out. PARAMETERS: p_alv RADIOBUTTON GROUP out DEFAULT 'X', p_list RADIOBUTTON GROUP out, p_prof AS CHECKBOX DEFAULT ' ', p_tex AS CHECKBOX DEFAULT ' '. SELECTION-SCREEN END OF BLOCK out. *---------------------------------------------------------------------- *--- event INITIALIZATION *---------------------------------------------------------------------- INITIALIZATION. PERFORM init. *---------------------------------------------------------------------- *--- Event START-OF-SELECTION *---------------------------------------------------------------------- START-OF-SELECTION. PERFORM main. *&---------------------------------------------------------------------* *& Form INIT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM init. DATA ls_agr_name LIKE LINE OF s_agrnam. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *--- define texts for selection screen 1000 sy-title = con_title. sel = 'Selections'. out = 'Output Options'. %_s_agrnam_%_app_%-text = 'Role Names'. %_p_alv_%_app_%-text = 'ALV Grid Display'. %_p_list_%_app_%-text = 'List Display (TeX Copy)'. %_p_prof_%_app_%-text = 'Display Profile Names'. %_p_tex_%_app_%-text = 'Doc: TeX Copy Template'. CLEAR: s_agrnam[], s_agrnam, ls_agr_name. ls_agr_name-sign = 'I'. ls_agr_name-option = 'CP'. ls_agr_name-low = '/EUTIN/*'. INSERT ls_agr_name INTO TABLE s_agrnam. IF sy-subrc NE 0. MESSAGE e252(s#) WITH 'Unexpected error:' 'FORM INIT' 'INSERT' sy-subrc. ENDIF. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ENDFORM. " INIT *&---------------------------------------------------------------------* *& Form MAIN *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM main. TYPES: BEGIN OF ts_tex_output, line TYPE c LENGTH 300, END OF ts_tex_output, BEGIN OF ts_output, agr_name TYPE agr_define-agr_name, counter TYPE agr_1250-counter, node TYPE agr_1250-node, auth TYPE agr_1250-auth, object TYPE agr_1250-object, field TYPE agr_1251-field, low TYPE agr_1251-low, high TYPE agr_1251-high, END OF ts_output. DATA: lr_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_sorts TYPE REF TO cl_salv_sorts, lr_salv_msg TYPE REF TO cx_salv_msg, lr_salv_not_found TYPE REF TO cx_salv_not_found, lr_salv_data_error TYPE REF TO cx_salv_data_error, lr_salv_existing TYPE REF TO cx_salv_existing, lr_root TYPE REF TO cx_root, lt_tex_output TYPE STANDARD TABLE OF ts_tex_output WITH DEFAULT KEY, lt_output TYPE STANDARD TABLE OF ts_output WITH DEFAULT KEY, lt_agr_texts TYPE STANDARD TABLE OF agr_texts WITH DEFAULT KEY, ls_tex_output LIKE LINE OF lt_tex_output, lv_error TYPE string, lv_title TYPE lvc_title, lv_agr_name TYPE c LENGTH 50, lv_agr_name_cond TYPE c LENGTH 50, lv_object TYPE c LENGTH 50, lv_field TYPE c LENGTH 50, lv_low TYPE c LENGTH 50, lv_high TYPE c LENGTH 50, lv_write_line TYPE c LENGTH 250, lv_value_high TYPE c LENGTH 1. FIELD-SYMBOLS: TYPE ts_output, TYPE agr_texts. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CLEAR: lt_tex_output[], lt_output[], lt_agr_texts[], ls_tex_output. SELECT a~agr_name b~counter b~node b~auth b~object c~field c~low c~high INTO TABLE lt_output FROM agr_define AS a INNER JOIN agr_1250 AS b ON b~agr_name EQ a~agr_name INNER JOIN agr_1251 AS c ON c~agr_name EQ b~agr_name AND c~auth EQ b~auth AND c~object EQ b~object" AND c~node EQ b~node WHERE a~agr_name IN s_agrnam. IF sy-subrc NE 0. MESSAGE 'Nothing found' TYPE 'S'. RETURN. ENDIF. SORT lt_output ASCENDING BY agr_name counter node auth object field low. lv_value_high = space. LOOP AT lt_output TRANSPORTING NO FIELDS WHERE high IS NOT INITIAL. *--- column HIGH contains value: do not hide it! lv_value_high = 'X'. EXIT. ENDLOOP. SELECT * INTO TABLE lt_agr_texts FROM agr_texts WHERE agr_name IN s_agrnam AND spras EQ 'E'. IF sy-subrc NE 0. CLEAR lt_agr_texts[]. ENDIF. SORT lt_agr_texts ASCENDING BY agr_name line. IF p_tex EQ 'X'. LOOP AT lt_output ASSIGNING . AT NEW agr_name. WRITE: / '%----------------------------------------------------------------------------------------'. lv_agr_name = -agr_name. REPLACE ALL OCCURRENCES OF '_' IN lv_agr_name WITH '\_'. lv_write_line = '\section{Role }\label{sec:Role}'. REPLACE FIRST OCCURRENCE OF '' IN lv_write_line WITH lv_agr_name. lv_agr_name = -agr_name. REPLACE ALL OCCURRENCES OF '_' IN lv_agr_name WITH ''. REPLACE FIRST OCCURRENCE OF '' IN lv_write_line WITH lv_agr_name. WRITE: / lv_write_line. READ TABLE lt_agr_texts ASSIGNING WITH KEY agr_name = -agr_name line = '00000'. IF sy-subrc EQ 0. WRITE -text. SKIP 1. LOOP AT lt_agr_texts ASSIGNING WHERE agr_name EQ -agr_name AND line GT '00000'. WRITE: / -text. ENDLOOP. ENDIF. SKIP 1. ENDAT. * AT NEW object. * ENDAT. * AT NEW field. * ENDAT. ENDLOOP. ELSE. CASE 'X'. WHEN p_list. CLEAR: lv_agr_name, lv_agr_name_cond, lv_object, lv_field, lv_low, lv_high. LOOP AT lt_output ASSIGNING . AT NEW agr_name. ls_tex_output-line = '%'. INSERT ls_tex_output INTO TABLE lt_tex_output. IF sy-subrc NE 0. MESSAGE 'INSERT failed' TYPE 'E'. ENDIF. ls_tex_output-line = '%====================================================================================================================================================================%'. INSERT ls_tex_output INTO TABLE lt_tex_output. IF sy-subrc NE 0. MESSAGE 'INSERT failed' TYPE 'E'. ENDIF. lv_agr_name = -agr_name. REPLACE ALL OCCURRENCES OF '_' IN lv_agr_name WITH '\_' IN CHARACTER MODE. CONCATENATE '\label{sec:ContentRole' -agr_name ')' INTO lv_agr_name_cond. TRANSLATE lv_agr_name_cond USING '_ '. CONDENSE lv_agr_name_cond NO-GAPS. CONCATENATE 'Content of the role \texttt{{\footnotesize' lv_agr_name '}} is listed in the following table:' lv_agr_name_cond '\\' INTO ls_tex_output-line SEPARATED BY space. INSERT ls_tex_output INTO TABLE lt_tex_output. IF sy-subrc NE 0. MESSAGE 'INSERT failed' TYPE 'E'. ENDIF. ls_tex_output-line = '\begin{tabu} to \textwidth {|>{\bfseries}X[2]|X[2]|X[5]|}'. INSERT ls_tex_output INTO TABLE lt_tex_output. IF sy-subrc NE 0. MESSAGE 'INSERT failed' TYPE 'E'. ENDIF. ls_tex_output-line = '\tableHeaderStyle'. INSERT ls_tex_output INTO TABLE lt_tex_output. IF sy-subrc NE 0. MESSAGE 'INSERT failed' TYPE 'E'. ENDIF. IF lv_value_high NE 'X'. ls_tex_output-line = 'Auth. Object & Field & Value \\'. ELSE. ls_tex_output-line = 'Auth. Object & Field & Low Value & High Value \\'. ENDIF. INSERT ls_tex_output INTO TABLE lt_tex_output. IF sy-subrc NE 0. MESSAGE 'INSERT failed' TYPE 'E'. ENDIF. ENDAT. AT NEW counter. CONCATENATE '\texttt{' -object '}' INTO lv_object. REPLACE ALL OCCURRENCES OF '_' IN lv_object WITH '\_' IN CHARACTER MODE. CONCATENATE '\texttt{' -field '}' INTO lv_field. REPLACE ALL OCCURRENCES OF '_' IN lv_field WITH '\_' IN CHARACTER MODE. ENDAT. AT NEW node. CONCATENATE '\texttt{' -object '}' INTO lv_object. REPLACE ALL OCCURRENCES OF '_' IN lv_object WITH '\_' IN CHARACTER MODE. CONCATENATE '\texttt{' -field '}' INTO lv_field. REPLACE ALL OCCURRENCES OF '_' IN lv_field WITH '\_' IN CHARACTER MODE. ENDAT. AT NEW object. CONCATENATE '\texttt{' -object '}' INTO lv_object. REPLACE ALL OCCURRENCES OF '_' IN lv_object WITH '\_' IN CHARACTER MODE. CONCATENATE '\texttt{' -field '}' INTO lv_field. REPLACE ALL OCCURRENCES OF '_' IN lv_field WITH '\_' IN CHARACTER MODE. ENDAT. AT NEW field. CONCATENATE '\texttt{' -field '}' INTO lv_field. REPLACE ALL OCCURRENCES OF '_' IN lv_field WITH '\_' IN CHARACTER MODE. ENDAT. CLEAR: lv_low, lv_high. IF -low IS NOT INITIAL. CONCATENATE '\texttt{' -low '}' INTO lv_low. REPLACE ALL OCCURRENCES OF '_' IN lv_low WITH '\_' IN CHARACTER MODE. ENDIF. IF lv_value_high NE 'X'. CONCATENATE lv_object '&' lv_field '&' lv_low '\\' INTO ls_tex_output-line SEPARATED BY space. ELSE. IF -high IS NOT INITIAL. CONCATENATE '\texttt{' -high '}' INTO lv_high. REPLACE ALL OCCURRENCES OF '_' IN lv_high WITH '\_' IN CHARACTER MODE. ENDIF. CONCATENATE lv_object '&' lv_field '&' lv_low '&' lv_high '\\' INTO ls_tex_output-line SEPARATED BY space. ENDIF. INSERT ls_tex_output INTO TABLE lt_tex_output. IF sy-subrc NE 0. MESSAGE 'INSERT failed' TYPE 'E'. ENDIF. *--- print authorization object and fiel just once CLEAR: lv_object, lv_field. ENDLOOP. IF sy-subrc EQ 0. ls_tex_output-line = '%====================================================================================================================================================================%'. INSERT ls_tex_output INTO TABLE lt_tex_output. IF sy-subrc NE 0. MESSAGE 'INSERT failed' TYPE 'E'. ENDIF. ls_tex_output-line = '%'. INSERT ls_tex_output INTO TABLE lt_tex_output. IF sy-subrc NE 0. MESSAGE 'INSERT failed' TYPE 'E'. ENDIF. ENDIF. LOOP AT lt_tex_output INTO ls_tex_output. WRITE: / ls_tex_output-line. ENDLOOP. WHEN p_alv. TRY. *--- create ALV table cl_salv_table=>factory( IMPORTING r_salv_table = lr_table CHANGING t_table = lt_output[] ). *--- activate all standard functions lr_functions_list = lr_table->get_functions( ). lr_functions_list->set_all( if_salv_c_bool_sap=>true ). *--- set optimized column size lr_columns_table = lr_table->get_columns( ). lr_columns_table->set_optimize( if_salv_c_bool_sap=>true ). *--- hide technical fields lr_column_table ?= lr_columns_table->get_column( 'COUNTER' ). lr_column_table->set_technical( if_salv_c_bool_sap=>true ). lr_column_table ?= lr_columns_table->get_column( 'NODE' ). lr_column_table->set_technical( if_salv_c_bool_sap=>true ). IF p_prof NE 'X'. lr_column_table ?= lr_columns_table->get_column( 'AUTH' ). lr_column_table->set_technical( if_salv_c_bool_sap=>true ). ENDIF. IF lv_value_high NE 'X'. lr_column_table ?= lr_columns_table->get_column( 'HIGH' ). lr_column_table->set_technical( if_salv_c_bool_sap=>true ). ENDIF. *--- set column header lr_column_table ?= lr_columns_table->get_column( 'AGR_NAME' ). lr_column_table->set_short_text( 'Role' ). lr_column_table->set_medium_text( 'Role' ). lr_column_table->set_long_text( 'Role' ). IF p_prof EQ 'X'. lr_column_table ?= lr_columns_table->get_column( 'AUTH' ). lr_column_table->set_short_text( 'Profile' ). lr_column_table->set_medium_text( 'Profile' ). lr_column_table->set_long_text( 'Profile' ). ENDIF. lr_column_table ?= lr_columns_table->get_column( 'OBJECT' ). lr_column_table->set_short_text( 'Object' ). lr_column_table->set_medium_text( 'Auth. Object' ). lr_column_table->set_long_text( 'Authorization Object' ). lr_column_table ?= lr_columns_table->get_column( 'FIELD' ). lr_column_table->set_short_text( 'Field' ). lr_column_table->set_medium_text( 'Auth. Field' ). lr_column_table->set_long_text( 'Authorization Field' ). lr_column_table ?= lr_columns_table->get_column( 'LOW' ). lr_column_table->set_short_text( 'Value: Low' ). lr_column_table->set_medium_text( 'Perm. Value: Low' ). lr_column_table->set_long_text( 'Permitted Value: Low' ). IF lv_value_high EQ 'X'. lr_column_table ?= lr_columns_table->get_column( 'HIGH' ). lr_column_table->set_short_text( 'Value:High' ). lr_column_table->set_medium_text( 'Perm. Value: High' ). lr_column_table->set_long_text( 'Permitted Value: High' ). ENDIF. *--- set zebra layout lr_display_settings = lr_table->get_display_settings( ). lr_display_settings->set_striped_pattern( if_salv_c_bool_sap=>true ). *--- set title DESCRIBE TABLE lt_output LINES sy-tfill. MESSAGE s252(s#) WITH 'Number records displayed:' "#EC NOTEXT sy-tfill space space INTO lv_title. lr_display_settings->set_list_header( lv_title ). *--- sort lr_sorts = lr_table->get_sorts( ). lr_sorts->add_sort( columnname = 'AGR_NAME' position = 1 sequence = if_salv_c_sort=>sort_up ). lr_sorts->add_sort( columnname = 'COUNTER' position = 2 sequence = if_salv_c_sort=>sort_up ). lr_sorts->add_sort( columnname = 'NODE' position = 3 sequence = if_salv_c_sort=>sort_up ). lr_sorts->add_sort( columnname = 'AUTH' position = 4 sequence = if_salv_c_sort=>sort_up ). lr_sorts->add_sort( columnname = 'OBJECT' position = 5 sequence = if_salv_c_sort=>sort_up ). lr_sorts->add_sort( columnname = 'FIELD' position = 6 sequence = if_salv_c_sort=>sort_up ). *--- display table lr_table->display( ). *--- error handling CATCH cx_salv_msg INTO lr_salv_msg. CLEAR lv_error. lv_error = lr_salv_msg->if_message~get_longtext( ). MESSAGE lv_error TYPE 'E'. CATCH cx_salv_not_found INTO lr_salv_not_found. CLEAR lv_error. lv_error = lr_salv_not_found->if_message~get_longtext( ). MESSAGE lv_error TYPE 'E'. CATCH cx_salv_data_error INTO lr_salv_data_error. CLEAR lv_error. lv_error = lr_salv_data_error->if_message~get_longtext( ). MESSAGE lv_error TYPE 'E'. CATCH cx_salv_existing INTO lr_salv_existing. CLEAR lv_error. lv_error = lr_salv_existing->if_message~get_longtext( ). MESSAGE lv_error TYPE 'E'. CATCH cx_root INTO lr_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 = lr_root->if_message~get_longtext( ). MESSAGE lv_error TYPE 'E'. ENDTRY. WHEN OTHERS. MESSAGE 'Output option is not supported' TYPE 'E'. ENDCASE. ENDIF. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ENDFORM. " MAIN *--- The End!