*----------------------------------------------------------------------* REPORT zfbc_monitor_fabio. *----------------------------------------------------------------------* * DECLARATIONS * *----------------------------------------------------------------------* DATA: BEGIN OF gs_out, name TYPE eps2filnam, datum TYPE crdate, uzeit LIKE sy-uzeit, pdf TYPE icon_d, END OF gs_out. DATA: gt_out LIKE STANDARD TABLE OF gs_out. DATA: gv_dirnam TYPE eps2filnam, gv_url(255) TYPE c, gv_content TYPE xstring, gv_fatt TYPE zflag_fatt, gv_lett TYPE zflag_lett, gv_canc TYPE zflag_canc, gv_ap TYPE zfbc_area. DATA: go_container_r TYPE REF TO cl_gui_container, go_container_l TYPE REF TO cl_gui_container, go_docking TYPE REF TO cl_gui_docking_container, go_splitter TYPE REF TO cl_gui_splitter_container, go_gui_html_viewer TYPE REF TO cl_gui_html_viewer, go_alv TYPE REF TO cl_salv_table. CLASS lcl_handle_events DEFINITION DEFERRED. DATA: go_events TYPE REF TO lcl_handle_events. DATA: ok_code TYPE syucomm. *---------------------------------------------------------------------* * CLASS lcl_handle_events DEFINITION * *---------------------------------------------------------------------* CLASS lcl_handle_events DEFINITION. PUBLIC SECTION. METHODS: on_user_command FOR EVENT added_function OF cl_salv_events_table IMPORTING e_salv_function, on_single_click FOR EVENT link_click OF cl_salv_events_table IMPORTING row column. ENDCLASS. *---------------------------------------------------------------------* * CLASS lcl_handle_events IMPLEMENTATION * *---------------------------------------------------------------------* CLASS lcl_handle_events IMPLEMENTATION. METHOD on_user_command. DATA: lv_answer TYPE c, lv_url(255) TYPE c, lo_selections TYPE REF TO cl_salv_selections, lt_rows TYPE salv_t_row, ls_row TYPE i, ls_cell TYPE salv_s_cell. CHECK e_salv_function = '&DEL'. lo_selections = go_alv->get_selections( ). lt_rows = lo_selections->get_selected_rows( ). CHECK lt_rows[] IS NOT INITIAL. CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING text_question = 'Sicuro di voler eliminare i file?' IMPORTING answer = lv_answer. CHECK lv_answer = '1'. LOOP AT lt_rows INTO ls_row. READ TABLE gt_out INTO gs_out INDEX ls_row. CONCATENATE gv_dirnam gs_out-name INTO lv_url. DELETE DATASET lv_url. CLEAR gs_out-name. MODIFY gt_out FROM gs_out INDEX ls_row TRANSPORTING name. CHECK lv_url = gv_url. lv_answer = 'D'. ENDLOOP. DELETE gt_out WHERE name IS INITIAL. CLEAR lt_rows[]. lo_selections->set_selected_rows( lt_rows[] ). ls_cell-row = 1. ls_cell-columnname = 'NAME'. lo_selections->set_current_cell( ls_cell ). go_alv->refresh( ). CHECK lv_answer = 'D'. IF gt_out[] IS NOT INITIAL. PERFORM preview_pdf USING 1. ELSE. CALL METHOD go_container_r->free EXCEPTIONS cntl_error = 1 cntl_system_error = 2 OTHERS = 3. CLEAR go_container_r. ENDIF. ENDMETHOD. METHOD on_single_click. CASE column. WHEN 'NAME'. PERFORM preview_pdf USING row. WHEN 'PDF'. PERFORM view_pdf USING row. ENDCASE. ENDMETHOD. ENDCLASS. *----------------------------------------------------------------------* * LAYOUT * *----------------------------------------------------------------------* SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001. SELECTION-SCREEN SKIP. SELECT-OPTIONS: so_datum FOR sy-datum DEFAULT sy-datum. PARAMETERS: pa_uname LIKE sy-uname DEFAULT sy-uname. SELECTION-SCREEN SKIP. SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT-004. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT (30) TEXT-002 MODIF ID id3. SELECTION-SCREEN COMMENT 31(30) TEXT-003 MODIF ID id3. SELECTION-SCREEN COMMENT 61(30) TEXT-011 MODIF ID id3. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. PARAMETERS: rb_fad RADIOBUTTON GROUP rbg1 MODIF ID id1. SELECTION-SCREEN COMMENT 3(27) TEXT-005 MODIF ID id1. PARAMETERS: rb_fai RADIOBUTTON GROUP rbg1 MODIF ID id1. SELECTION-SCREEN COMMENT 33(27) TEXT-005 MODIF ID id1. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. PARAMETERS: rb_lnd RADIOBUTTON GROUP rbg1 MODIF ID id2 DEFAULT 'X'. SELECTION-SCREEN COMMENT 3(27) TEXT-006 MODIF ID id2. PARAMETERS: rb_lni RADIOBUTTON GROUP rbg1 MODIF ID id2. SELECTION-SCREEN COMMENT 33(27) TEXT-006 MODIF ID id2. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. PARAMETERS: rb_lsd RADIOBUTTON GROUP rbg1 MODIF ID id4. SELECTION-SCREEN COMMENT 3(27) TEXT-007 MODIF ID id4. PARAMETERS: rb_lsi RADIOBUTTON GROUP rbg1 MODIF ID id4. SELECTION-SCREEN COMMENT 33(27) TEXT-007 MODIF ID id4. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. PARAMETERS: rb_lcd RADIOBUTTON GROUP rbg1 MODIF ID id4. SELECTION-SCREEN COMMENT 3(27) TEXT-009 MODIF ID id4. PARAMETERS: rb_lci RADIOBUTTON GROUP rbg1 MODIF ID id4. SELECTION-SCREEN COMMENT 33(27) TEXT-009 MODIF ID id4. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. PARAMETERS: rb_lgd RADIOBUTTON GROUP rbg1 MODIF ID id5. SELECTION-SCREEN COMMENT 3(27) TEXT-010 MODIF ID id5. PARAMETERS: rb_lgi RADIOBUTTON GROUP rbg1 MODIF ID id5. SELECTION-SCREEN COMMENT 33(27) TEXT-010 MODIF ID id5. PARAMETERS: rb_lgn RADIOBUTTON GROUP rbg1 MODIF ID id5. SELECTION-SCREEN COMMENT 63(27) TEXT-010 MODIF ID id5. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN END OF BLOCK b2. SELECTION-SCREEN END OF BLOCK b1. *----------------------------------------------------------------------* * EVENTS * *----------------------------------------------------------------------* AT SELECTION-SCREEN OUTPUT. LOOP AT SCREEN. IF screen-group1 = 'ID1' AND gv_fatt IS INITIAL. screen-output = 0. screen-input = 0. screen-active = 0. MODIFY SCREEN. ENDIF. IF screen-group1 = 'ID2' AND gv_lett IS INITIAL. screen-output = 0. screen-input = 0. screen-active = 0. MODIFY SCREEN. ENDIF. IF screen-group1 = 'ID3'. screen-intensified = 1. MODIFY SCREEN. ENDIF. IF screen-group1 = 'ID4' AND gv_lett IS INITIAL. screen-output = 0. screen-input = 0. screen-active = 0. MODIFY SCREEN. ENDIF. IF screen-group1 = 'ID5' AND gv_lett IS INITIAL. screen-output = 0. screen-input = 0. screen-active = 0. MODIFY SCREEN. ENDIF. ENDLOOP. *----------------------------------------------------------------------* * INIT * *----------------------------------------------------------------------* INITIALIZATION. SELECT SINGLE flag_fatt flag_lett flag_canc FROM zfbc_mon_fabio_a INTO (gv_fatt, gv_lett, gv_canc) WHERE uname = sy-uname. REFRESH so_datum[]. so_datum-low = sy-datum - 7. so_datum-high = sy-datum. so_datum-option = 'BT'. so_datum-sign = 'I'. APPEND so_datum. CLEAR so_datum. *----------------------------------------------------------------------* * PROGRAM BODY * *----------------------------------------------------------------------* START-OF-SELECTION. PERFORM dir_list. END-OF-SELECTION. CHECK gt_out[] IS NOT INITIAL. CALL SCREEN 100. *----------------------------------------------------------------------* * * * ####### ####### ####### * * ### ### ### ### #### #### * * ### ### ### ### ### ### * * ####### ####### ### ### * * ### ### ### ### ### * * ### ### ### #### #### * * ### ####### ####### * * * *----------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Module STATUS_0100 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE status_0100 OUTPUT. SET PF-STATUS 'D0100'. SET TITLEBAR 'D0100'. PERFORM output_alv. ENDMODULE. *----------------------------------------------------------------------* * * * ####### ###### ### * * ### ### ### ### ### * * ### ### ### ### ### * * ####### ######## ### * * ### ### ### ### * * ### ### ### ### * * ### ### ### ### * * * *----------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE user_command_0100 INPUT. PERFORM user_command. ENDMODULE. *----------------------------------------------------------------------* * * * ######## ####### ####### #### #### ######## * * ######## #### #### ### ### ##### ##### ######## * * ###### ### ### ### ### ########### ##### * * ###### ### ### ####### ########### ######## * * ### ### ### ### ### ### ### ### ##### * * ### #### #### ### ### ### ### ######## * * ### ####### ### ### ### ### ######## * * * *----------------------------------------------------------------------* *----------------------------------------------------------------------* * FORM DIR_LIST * *----------------------------------------------------------------------* FORM dir_list. CONSTANTS: lc_days1980 TYPE i VALUE 3652, lc_hours TYPE uzeit VALUE '020000'. DATA: lt_dir TYPE STANDARD TABLE OF eps2fili, ls_dir LIKE LINE OF lt_dir. DATA: lv_pit TYPE i, lv_mtime(12) TYPE c. DATA: ls_path TYPE zfbc_path_postel. DATA: path_ln TYPE string, path_ls TYPE string, path_lc TYPE string, path_lg TYPE string, path_ft TYPE string. SELECT DISTINCT * FROM zfbc_path_postel INTO ls_path WHERE area_app = 'LT'. ENDSELECT. IF sy-subrc = 0. path_ln = ls_path-path_ln. path_ls = ls_path-path_ls. path_lc = ls_path-path_lc. path_lg = ls_path-path_lg. REPLACE ALL OCCURRENCES OF 'SYSID' IN path_ln WITH sy-sysid. REPLACE ALL OCCURRENCES OF 'SYSID' IN path_ls WITH sy-sysid. REPLACE ALL OCCURRENCES OF 'SYSID' IN path_lc WITH sy-sysid. REPLACE ALL OCCURRENCES OF 'SYSID' IN path_lg WITH sy-sysid. ENDIF. SELECT DISTINCT * FROM zfbc_path_postel INTO ls_path WHERE area_app = 'FT'. ENDSELECT. IF sy-subrc = 0. path_ft = ls_path-path_ln. REPLACE ALL OCCURRENCES OF 'SYSID' IN path_ft WITH sy-sysid. ENDIF. CASE 'X'. WHEN rb_fad. gv_dirnam = path_ft. WHEN rb_lnd. gv_dirnam = path_ln. WHEN rb_lsd. gv_dirnam = path_ls. WHEN rb_lcd. gv_dirnam = path_lc. WHEN rb_lgd. gv_dirnam = path_lg. WHEN rb_fai. REPLACE ALL OCCURRENCES OF '/FABIO/' IN path_ft WITH '/FABIO/SENT/'. gv_dirnam = path_ft. WHEN rb_lni. REPLACE ALL OCCURRENCES OF '/FABIO/' IN path_ln WITH '/FABIO/SENT/'. gv_dirnam = path_ln. WHEN rb_lsi. REPLACE ALL OCCURRENCES OF '/FABIO/' IN path_ls WITH '/FABIO/SENT/'. gv_dirnam = path_ls. WHEN rb_lci. REPLACE ALL OCCURRENCES OF '/FABIO/' IN path_lc WITH '/FABIO/SENT/'. gv_dirnam = path_lc. WHEN rb_lgi. REPLACE ALL OCCURRENCES OF '/FABIO/' IN path_lg WITH '/FABIO/SENT/'. gv_dirnam = path_lg. WHEN rb_lgn. CONCATENATE path_lg '/NO_FABIO/' INTO path_lg. gv_dirnam = path_lg. ENDCASE. CALL FUNCTION 'EPS2_GET_DIRECTORY_LISTING' EXPORTING iv_dir_name = gv_dirnam TABLES dir_list = lt_dir EXCEPTIONS invalid_eps_subdir = 1 sapgparam_failed = 2 build_directory_failed = 3 no_authorization = 4 read_directory_failed = 5 too_many_read_errors = 6 empty_directory_list = 7. IF sy-subrc <> 0 OR lt_dir[] IS INITIAL. MESSAGE i208(00) WITH TEXT-008. EXIT. ENDIF. gs_out-pdf = '@IT@'. LOOP AT lt_dir INTO ls_dir WHERE name CP '*.PDF'. gs_out-name = ls_dir-name. CONCATENATE ls_dir-mtim+6(4) ls_dir-mtim+3(2) ls_dir-mtim(2) INTO gs_out-datum. CONCATENATE ls_dir-mtim+11(2) ls_dir-mtim+14(2) ls_dir-mtim+17(2) INTO gs_out-uzeit. CHECK gs_out-datum IN so_datum. CHECK gs_out-datum IN so_datum. IF pa_uname IS NOT INITIAL. IF gs_out-name CS pa_uname. APPEND gs_out TO gt_out. ENDIF. ELSE. APPEND gs_out TO gt_out. ENDIF. ENDLOOP. IF gt_out[] IS INITIAL. MESSAGE i208(00) WITH TEXT-008. EXIT. ELSE. SORT gt_out. ENDIF. ENDFORM. *----------------------------------------------------------------------* * FORM OUTPUT_ALV * *----------------------------------------------------------------------* FORM output_alv. CLEAR: go_docking, go_splitter, go_container_l, go_container_r. CREATE OBJECT go_docking EXPORTING repid = sy-repid dynnr = '0100' ratio = '95'. "--max container length * Create a splitter with 1 row and 2 column CREATE OBJECT go_splitter EXPORTING parent = go_docking rows = 1 columns = 2. ** Right Container go_splitter->get_container( EXPORTING row = 1 column = 2 RECEIVING container = go_container_r ). ** Left Container go_splitter->get_container( EXPORTING row = 1 column = 1 RECEIVING container = go_container_l ). CREATE OBJECT go_gui_html_viewer EXPORTING parent = go_container_r. PERFORM preview_pdf USING 1. TRY. cl_salv_table=>factory( EXPORTING r_container = go_container_l IMPORTING r_salv_table = go_alv CHANGING t_table = gt_out ). PERFORM set_settings. go_alv->display( ). CATCH cx_salv_msg. " error handling RETURN. ENDTRY. ENDFORM. *----------------------------------------------------------------------* * FORM SET_SETTINGS * *----------------------------------------------------------------------* FORM set_settings. DATA: ls_key TYPE salv_s_layout_key, lo_cols TYPE REF TO cl_salv_columns_table, lo_col TYPE REF TO cl_salv_column_table, lo_funcs TYPE REF TO cl_salv_functions_list, lo_layout TYPE REF TO cl_salv_layout, lo_display TYPE REF TO cl_salv_display_settings, lo_selections TYPE REF TO cl_salv_selections, lo_events TYPE REF TO cl_salv_events_table. *Events lo_events = go_alv->get_event( ). CREATE OBJECT go_events. SET HANDLER go_events->on_user_command FOR lo_events. SET HANDLER go_events->on_single_click FOR lo_events. *Columns lo_cols = go_alv->get_columns( ). TRY. lo_col ?= lo_cols->get_column( 'NAME' ). lo_col->set_cell_type( if_salv_c_cell_type=>hotspot ). lo_col ?= lo_cols->get_column( 'PDF' ). lo_col->set_cell_type( if_salv_c_cell_type=>button ). lo_col->set_short_text( 'View Pdf' ). CATCH cx_salv_error. " error handling RETURN. ENDTRY. lo_cols->set_optimize( 'X' ). *Layouts ls_key-report = sy-repid. lo_layout = go_alv->get_layout( ). lo_layout->set_key( ls_key ). lo_layout->set_default( 'X' ). lo_layout->set_save_restriction( ). *Functions lo_funcs = go_alv->get_functions( ). lo_funcs->set_all( ). IF ( rb_fad = 'X' OR rb_lnd = 'X' OR rb_lsd = 'X' OR rb_lcd = 'X' ) AND gv_canc = 'X'. TRY. lo_funcs->add_function( name = '&DEL' icon = '@11@' text = '' tooltip = 'Eliminare' position = if_salv_c_function_position=>right_of_salv_functions ). CATCH cx_salv_wrong_call. " error handling RETURN. ENDTRY. ENDIF. *Display Settings lo_display = go_alv->get_display_settings( ). lo_display->set_striped_pattern( 'X' ). *Selections lo_selections = go_alv->get_selections( ). lo_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ). ENDFORM. *----------------------------------------------------------------------* * FORM USER_COMMAND * *----------------------------------------------------------------------* FORM user_command. CASE ok_code. WHEN 'BACK' OR 'EXIT' OR 'CANC'. SET SCREEN 0. LEAVE SCREEN. ENDCASE. ENDFORM. *----------------------------------------------------------------------* * FORM PREVIEW_PDF * *----------------------------------------------------------------------* FORM preview_pdf USING pf_row TYPE i. DATA: lv_url(255) TYPE c, lt_data TYPE STANDARD TABLE OF x255. READ TABLE gt_out INTO gs_out INDEX pf_row. CONCATENATE gv_dirnam gs_out-name INTO gv_url. OPEN DATASET gv_url FOR INPUT IN BINARY MODE. CHECK sy-subrc = 0. READ DATASET gv_url INTO gv_content. CLOSE DATASET gv_url. CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING buffer = gv_content TABLES binary_tab = lt_data. go_gui_html_viewer->load_data( EXPORTING type = 'application' subtype = 'pdf' IMPORTING assigned_url = lv_url CHANGING data_table = lt_data EXCEPTIONS dp_invalid_parameter = 1 dp_error_general = 2 cntl_error = 3 OTHERS = 4 ). go_gui_html_viewer->show_url( url = lv_url in_place = 'X' ). ENDFORM. *----------------------------------------------------------------------* * FORM VIEW_PDF * *----------------------------------------------------------------------* FORM view_pdf USING pf_row TYPE i. DATA: lv_url(255) TYPE c, lv_content TYPE xstring. READ TABLE gt_out INTO gs_out INDEX pf_row. CONCATENATE gv_dirnam gs_out-name INTO lv_url. IF lv_url <> gv_url. OPEN DATASET lv_url FOR INPUT IN BINARY MODE. CHECK sy-subrc = 0. READ DATASET lv_url INTO lv_content. CLOSE DATASET lv_url. ELSE. lv_content = gv_content. ENDIF. CALL FUNCTION 'ISH_DALE_PDF_DISPLAY' EXPORTING i_pdf = lv_content. ENDFORM. *----------------------------------------------------------------------*
martedì 1 giugno 2021
Bottoni dentro tabella ALV
Iscriviti a:
Commenti sul post (Atom)
Nessun commento:
Posta un commento