CL GUI FRONTEND SERVICES

Aus SAP Wiki ツ

Datei Download von Applikations- zu Pränsentationsserver

"Read file from application server and get datasets from file
       cl_rsan_ut_appserv_file_reader=>appserver_file_read( EXPORTING i_filename = lv_path_filename
                                                           CHANGING c_data_tab = gt_data_tab ).
      gt_table = gt_data_tab.

       "Open dialog for saving and path for saving on client
       cl_gui_frontend_services=>file_save_dialog( EXPORTING window_title = 'Template Download'
                                                             default_file_name = lv_def_file_name
                                                             default_extension = 'csv'
                                                             file_filter = '*.csv'
                                                   CHANGING filename = gv_filename
                                                            path = gv_path
                                                            fullpath = gv_path_file ).

       "Build file like read and save it to client path link
       cl_gui_frontend_services=>gui_download( EXPORTING filename = gv_path_file
                                             CHANGING data_tab = gt_table ).

Datei Upload vom Pränsentations- zum Applikationsserver

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_up.
 TRY.
     p_doshow = .
     p_dodown = .
     IF p_doshow <> abap_true AND p_dodown <> abap_true.
       gv_title = 'Download file selection for template'(001).
       cl_gui_frontend_services=>file_open_dialog( EXPORTING window_title = gv_title
                                                   CHANGING file_table  = gt_filename
                                                            rc          = gv_cnt
                                                            user_action = gv_action ).
       IF gv_cnt > 1.
         MESSAGE e062(cacsib_edt).
       ELSE.
         IF NOT gv_cnt < 1.
           READ TABLE gt_filename INTO p_up INDEX 1.
         ENDIF.
       ENDIF.
     ENDIF.
   CATCH zcx_bc_basic INTO go_cx_bc_basic.
     gs_message_bal_msg = go_cx_bc_basic->get_msg_in_bal_structure( ).
     APPEND gs_message_bal_msg TO gt_messages_bal_msg.
 ENDTRY.

gv_path_filename = p_up.
       "Upload from client to application server
       cl_gui_frontend_services=>gui_upload( EXPORTING filename = gv_path_filename
                                             CHANGING data_tab = gt_table ).
       gt_data_tab = gt_table.

       "File from Path
       lcl_utilities=>get_filename_from_path( EXPORTING iv_path_filename = gv_path_filename IMPORTING ev_filename = gv_filename ).

       "Rename it with Filename pattern from cust table and date/time stamp
       lcl_utilities=>rename_build_to_dir_path( EXPORTING iv_filename = gv_filename
                                                          io_cust = go_cust
                                                IMPORTING ev_path_filename = gv_to_dir_file ).

       "Write file to application server
       cl_rsan_ut_appserv_file_writer=>appserver_file_write( EXPORTING i_filename = gv_to_dir_file
                                                                       i_data_tab = gt_data_tab
                                                                       i_overwrite = abap_true
                                                             IMPORTING e_lines_written = DATA(gv_lines_written) ).