实现FTP的文件上传与下载
Posted 独吊东南枝
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实现FTP的文件上传与下载相关的知识,希望对你有一定的参考价值。
*FTP_CONNECT:通过账号连接FTP
*FTP_COMMAND:执行FTP操作命令(注意,程序中所有命令必须为小写)
*lcd:指定本地文件夹路径
*cd:指定FTP文件夹路径
*put<filename>:上传文件
*get<filename>:下载文件
*FTP_SERVER_TO_R3:将FTP上的指定文本文件数据读取到内表
*FTP_DISCONNECT:关闭FTP连接
DATA:key TYPE i VALUE 2610957,
trfcdest LIKE rfcdes-rfcdest,
thandle TYPE i.
INCLUDE:<icon>.
*定义输入界面
SELECTION-SCREEN:BEGIN OF BLOCK ftplogin WITH FRAME TITLE text-001.
PARAMETERS:p_user(45) LOWER CASE OBLIGATORY MEMORY ID usr,
p_pwd(45) MODIF ID pwd LOWER CASE OBLIGATORY MEMORY ID pwd,
p_host(15) MEMORY ID hos OBLIGATORY,
ftp_path(30) MEMORY ID fpos OBLIGATORY.
SELECTION-SCREEN:END OF BLOCK ftplogin.
SELECTION-SCREEN:BEGIN OF BLOCK upload WITH FRAME TITLE text-002.
PARAMETERS:p_uppath(45),
p_file(20).
SELECTION-SCREEN:BEGIN OF LINE.
SELECTION-SCREEN:PUSHBUTTON 1(20) pubu USER-COMMAND upload.
SELECTION-SCREEN:END OF LINE.
SELECTION-SCREEN:END OF BLOCK upload.
SELECTION-SCREEN:BEGIN OF BLOCK download WITH FRAME TITLE text-003.
PARAMETERS:dl_path(45),
dl_file(20).
SELECTION-SCREEN:BEGIN OF LINE.
SELECTION-SCREEN:PUSHBUTTON 1(20) gebu USER-COMMAND download.
SELECTION-SCREEN:PUSHBUTTON 24(30) shbu USER-COMMAND itab_dl.
SELECTION-SCREEN:END OF LINE.
SELECTION-SCREEN:END OF BLOCK download.
AT SELECTION-SCREEN OUTPUT.
*对密码输入栏进行加密处理
PERFORM mask_pwd.
*给各按钮加入文本及图标
WRITE icon_outgoing_object AS ICON TO pubu.
CONCATENATE pubu ‘Upload FTP‘ INTO pubu SEPARATED BY space.
WRITE icon_incoming_object AS ICON TO gebu.
CONCATENATE gebu ‘FTP Download‘ INTO gebu SEPARATED BY space.
WRITE icon_write_file AS ICON TO shbu.
CONCATENATE shbu ‘Internal table download‘ INTO shbu SEPARATED BY space.
AT SELECTION-SCREEN.
PERFORM ftpconnect.
IF sy-subrc <> 0.
MESSAGE i001(00) WITH ‘Can‘‘t connect FTP!‘.
EXIT.
ENDIF.
MESSAGE s001(00) WITH ‘FTP connect OK!‘.
CASE sy