Uygulama sunucusundan dosya indirme
AL11`e yüklenmiş dosyaların indirilmesi :
form download_files using prm_directory type afilename
prm_tcode type tcode .
data: prm_filename type afilename.
concatenate prm_tcode `.pdf` into prm_filename.
constants blocksize type i value 524287.
constants packagesize type i value 8.
types ty_datablock(blocksize) type x.
data lv_package_len type i.
data lv_subrc type sy-subrc.
data lv_block_len type i.
data: lv_full_path type string.
data lv_msgv1 like sy-msgv1.
data lv_filesize type p.
data ls_data type ty_datablock.
data lt_data type standard table of ty_datablock.
data: lv_eps_filename type epsfilnam,
lv_eps_dirname type epsdirnam,
lv_dosya_adi_varsayilan type string.
lv_eps_dirname = prm_directory .
lv_eps_filename = prm_filename .
concatenate prm_directory `/` prm_filename into lv_full_path.
call function `EPS_GET_FILE_ATTRIBUTES`
exporting
file_name = lv_eps_filename
dir_name = lv_eps_dirname
importing
file_size_long = lv_filesize
exceptions
read_directory_failed
read_attributes_failed.
"Open the file on application server
open dataset lv_full_path for input in binary mode message lv_msgv1.
if sy-subrc <> 0.
message e048(cms) with lv_full_path lv_msgv1 raising file_read_error.
exit.
endif.
do.
refresh lt_data.
lv_package_len = 0.
do packagesize times.
clear ls_data.
clear lv_block_len.
read dataset lv_full_path into ls_data maximum length blocksize length lv_block_len.
lv_subrc = sy-subrc.
if lv_block_len > 0.
lv_package_len = lv_package_len + lv_block_len.
append ls_data to lt_data.
endif.
"End of file
if lv_subrc <> 0.
exit.
endif.
enddo.
if lv_package_len > 0.
data: lv_str_filename type string.
data: lv_str_path type string.
data: lv_str_fullpath type string.
lv_dosya_adi_varsayilan = prm_filename.
call method cl_gui_frontend_services=>file_save_dialog
exporting
* window_title =
default_extension = `XLSX`
default_file_name = lv_dosya_adi_varsayilan
* with_encoding =
* file_filter =
* initial_directory =
* prompt_on_overwrite = `X`
changing
filename = lv_str_filename
path = lv_str_path
fullpath = lv_str_fullpath
* user_action =
* file_encoding =
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
if sy-subrc eq 0.
call function `GUI_DOWNLOAD`
exporting
bin_filesize = lv_package_len
filename = lv_str_fullpath
filetype = `BIN`
append = `` "lv_append
show_transfer_status = abap_false
tables
data_tab = lt_data.
endif.
endif.
"End of file
if lv_subrc <> 0.
exit.
endif.
enddo.
"Close the file on application server
close dataset lv_full_path.
endform. "#download_files