ITPub博客

首页 > IT基础架构 > 网络安全 > 【ABAP】FTP Program

【ABAP】FTP Program

原创 网络安全 作者:sapkitty 时间:2013-04-11 09:44:23 0 删除 编辑

ABAP FTP Program

[@more@]

-------------------------------------------------------------------------------

DATA: l_hdl TYPE i,
l_key TYPE i VALUE 26101957,
l_slen TYPE i,
l_compress TYPE c VALUE 'N',
l_ftp_filename(80) TYPE c,
l_cmd(80) TYPE c .

DATA: ls_result TYPE ts_cmd_result,
lt_result LIKE TABLE OF ls_result.

l_slen = STRLEN( pwd ).

CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = pwd
sourcelen = l_slen
key = l_key
IMPORTING
destination = pwd.

CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = user
password = pwd
host = host
rfc_destination = dest
IMPORTING
handle = l_hdl.

*enter directory
CONCATENATE 'cd' pa_filea INTO l_cmd SEPARATED BY space.
PERFORM exec_command USING l_hdl l_cmd l_compress CHANGING lt_result.

"CONCATENATE host pa_filea INTO l_fname.
PERFORM filename_timestamp CHANGING l_ftp_filename.

CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
handle = l_hdl
fname = l_ftp_filename
character_mode = 'X'
TABLES
text = gt_record.

IF sy-subrc = 0.
MESSAGE s013.
ENDIF.

* Disconnect
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = l_hdl.

CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = dest
EXCEPTIONS
OTHERS = 1.

-------------------------------------------------------------------------------

FORM exec_command USING p_hdl
p_cmd
p_compress
CHANGING pt_result TYPE tt_cmd_result.

CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = p_hdl
command = p_cmd
compress = p_compress
TABLES
data = pt_result
EXCEPTIONS
command_error = 1
tcpip_error = 2.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " EXEC_COMMAND

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8214011/viewspace-1060385/,如需转载,请注明出处,否则将追究法律责任。

下一篇: ftp
请登录后发表评论 登录
全部评论

注册时间:2008-08-04

  • 博文量
    62
  • 访问量
    204763