网络盘中保存文件:* 直接使用 UTF-8
* open dataset gv_file_6040 for output in text mode encoding default.
open dataset gv_file_6040 for output in text mode encoding UTF-8 WITH BYTE-ORDER MARK
WITH SMART LINEFEED.
loop at itab_file_6040.
condense itab_file_6040-line.
transfer itab_file_6040-line to gv_file_6040.
endloop.
close dataset gv_file_6040.
下载本地,并使用 UTF-8 格式
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
CODEPAGE = '4110'
FILENAME = file_name
FILETYPE = 'ASC'
WRITE_BOM = 'X'
TABLES
DATA_TAB = itab
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
下载文件时使用 TAB 分隔:
concatenate wa_ind
itab-vbeln
itab-qnum
ITAB-ZPROJ_STS
into itab_file_5020 separated by
cl_abap_char_utilities=>horizontal_tab.
本地保存文件:
*&---------------------------------------------------------------------*
*& Form download_local
*&---------------------------------------------------------------------*
form download_local.
read table itab_file2 index 1.
if sy-subrc eq 0.
call function 'WS_DOWNLOAD'
exporting
filename = gv_file
filetype = 'ASC'
tables
data_tab = itab_file2
exceptions
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
others = 10
.
if sy-subrc <> 0.
endif.
endif.
ENDForm.