编写上传和下载程序示例的方法
REPORT Z_HO_TTT .
parameters: pm_cr type TRKORR obligatory.
data: c_file(80), d_file(80).
DATA: C_L TYPE STRING, D_L TYPE STRING.
data: str(12).
str = pm_cr.
*shift str left by 3 places.
*str+7(1) = '.'.
*str+8(3) = pm_cr(3).
concatenate '/usr/sap/trans/cofiles/' pm_cr into c_file.
CONCATENATE 'C:/' pm_cr INTO C_L.
str(1) = 'R'.
concatenate '/usr/sap/trans/data/' pm_cr INTO D_FILE.
CONCATENATE 'C:/' pm_cr INTO D_L.
DATA: BEGIN OF I_LIST OCCURS 0,
STR(500),
END OF I_LIST.
DATA: I TYPE I, J TYPE I.
*文本文件下载
OPEN DATASET C_FILE FOR INPUT IN TEXT MODE.
DO.
READ DATASET C_FILE INTO I_LIST.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
APPEND I_LIST.
ENDDO.
close dataset c_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = C_L
* FILETYPE = 'ASC'
tables
data_tab = I_LIST
.
REFRESH I_LIST.
CLEAR: I_LIST.
CLEAR: I.
*二进值文件下载
OPEN DATASET D_FILE FOR INPUT IN BINARY MODE.
DO.
READ DATASET D_FILE INTO I_LIST LENGTH J.
IF SY-SUBRC NE 0 AND J = 0.
EXIT.
ENDIF.
I = I + J.
APPEND I_LIST.
ENDDO.
close dataset D_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = I
filename = D_L
FILETYPE = 'BIN'
tables
data_tab = I_LIST.
本文地址:http://www.45fan.com/a/question/72623.html