AL11 Upload
Uygulama sunucusuna dosya ekleme, sunucudan dosya indirme.
CG3Y CG3Z işlem kodları
CG3Z işlem kodu ile dosyayı sunucuya yüklüyoruz.
Burada hedef klasör tmp/
CG3Y ile yüklenmiş bir dosyayı indirebiliriz.
Örnek Abap Kodu
constants gc_directory type afilename value `/tmp`.
constants gc_filename_yenileme type afilename value `ZCD0077.xlsx`.
PERFORM download_files using gc_directory gc_filename_yenileme .
*&---------------------------------------------------------------------*
*& Form download_files
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PRM_DIRECTORY text
* -->PRM_FILENAME text
*----------------------------------------------------------------------*
FORM download_files USING prm_directory TYPE afilename
prm_filename TYPE afilename .
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.
"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
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; }