Download Internal Table to File Excel

  REPORT zdoanlowd_excel.
 
   DATABEGIN OF t_download OCCURS 0,
           date TYPE datum,
           day TYPE langt,
         END OF t_download.
 
   DATAd_count TYPE i.
   DATAd_filename TYPE string,
         d_path TYPE string,
         d_fullpath TYPE string,
         d_result TYPE i,
         d_default_fname TYPE string,
         d_fname LIKE rlgrap-filename.
 
   DO TIMES.
     ADD TO d_count.
     t_download-date sy-datum + d_count.
 
     CALL FUNCTION 'FTR_DAY_GET_TEXT'
       EXPORTING
         pi_date      t_download-date
       IMPORTING
         pe_day_text2 t_download-day.
 
     APPEND t_downloadCLEAR t_download.
   ENDDO.
 
   CALL METHOD cl_gui_frontend_services=>file_save_dialog
     EXPORTING
       window_title      'File Directory'
       default_extension 'XLS'
       initial_directory 'D:\'
     CHANGING
       filename          d_filename
       path              d_path
       fullpath          d_fullpath
       user_action       d_result.
 
   CHECK sy-subrc 0.
 
   d_fname d_filename.
 
   CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
     EXPORTING
       i_filename        d_fname
     TABLES
       i_tab_sap_data    t_download
     EXCEPTIONS
       conversion_failed 1
       OTHERS            2.
   IF sy-subrc 0.
     MESSAGE i006(aqWITH 'File was downloaded'.
   ENDIF.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: