sap 服务器文件上传和下载收藏
data remote_file like rcgfiletr-ftappl."远程文件类型
data local_file like rcgfiletr-ftfront."下载文件类型
remote_file = '/usr/sap/trans/excel/Dawning_BS.xls'.
local_file = 'c:\dawning_sap_excel\Dawning_BS.xls'.
"从服务器上下载Excel文件到本地
call function 'C13Z_FILE_DOWNLOAD_BINARY'
exporting
i_file_front_end = local_file
i_file_appl = remote_file
i_file_overwrite = 'X'
exceptions
fe_file_open_error = 1
fe_file_exists = 2
fe_file_write_error = 3
ap_no_authority = 4
ap_file_open_error = 5
ap_file_empty = 6
others = 7.
*上传
CALL FUNCTION 'C13Z_FILE_UPLOAD_BINARY'
EXPORTING
i_file_front_end = local_file
i_file_appl = remote_file
* I_FILE_OVERWRITE = ESP1_FALSE
* IMPORTING
* E_FLG_OPEN_ERROR =
* E_OS_MESSAGE =
* EXCEPTIONS
* FE_FILE_NOT_EXISTS = 1
* FE_FILE_READ_ERROR = 2
* AP_NO_AUTHORITY = 3
* AP_FILE_OPEN_ERROR = 4
* AP_FILE_EXISTS = 5
* OTHERS = 6
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
上传用下面这个 更保险:
report z_lijia_06 .
data: fname type rlgrap-filename,
ftype type rlgrap-filetype,
fsize type i.
data: fname_p type string,
fname_n type string.
data: sfname_p type string .
data: sfname like rcgiedial-iefile.
sfname_p = '/usr/sap/trans/excel/'."上传报表模板文件路径
data: r(1) type c.
data: data_tab like rcgrepfile occurs 10 with header line.
data: lines type i.
call function 'UPLOAD'
exporting
* codepage = 'IBM'
filename = 'C:\EXCEL_DATA'
filetype = 'BIN'
* filemask_mask = '*.XLS'
* FILESMASK_TEXT = 'XLS'
filetype_no_change = 'X'
* SILENT = 'X'
* item = ''
importing
filesize = fsize
act_filename = fname
act_filetype = ftype
tables
data_tab = data_tab
exceptions
conversion_error = 1
invalid_table_width = 2
invalid_type = 3.
fname_n = fname.
do.
split fname_n at '\' into fname_p fname_n.
search fname_n for '\'.
if sy-subrc = 4.
exit.
endif.
enddo.
fname_p = fname.
shift fname_p right deleting trailing fname_n.
shift fname_p left deleting leading space.
*write:/,'fname_p=',fname_p,'|',
* /,'fname_n=',fname_n,'|'.
concatenate sfname_p fname_n into sfname.
*write:/,'sfname=',sfname,'|'.
describe table data_tab lines lines.
call function 'C13Z_RAWDATA_WRITE'
exporting
i_file = sfname
i_file_size = fsize
i_lines = lines
tables
i_rcgrepfile_tab = data_tab
exceptions
no_permission = 1
open_failed = 2
others = 3.
*IF sy-subrc NE 0.
* MESSAGE s000 WITH 'UPLOAD SUCC'.
*ENDIF.
write: 'SY-SUBRC:', sy-subrc,
/ '上载的本地文件名:', (60) fname,
/ '上载的远程文件名:',(60) sfname,
/ '文件类型:', ftype,
/ '文件大小:', fsize.
阅读(2099) | 评论(0) | 转发(0) |