批量上传SAP服务器文件至FTP服务器

本文介绍了一个使用 SAP 系统进行 FTP 连接及文件传输的例子。通过 HTTP_SCRAMBLE 和 FTP_CONNECT 函数实现密码加密及 FTP 会话建立,并展示了如何构建 FTP 命令列表,完成指定目录下文件的上传。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


report  ztest131 message-id zmsg line-size 136 line-count 33
no standard page heading.
data: user(30type value 'sap' ,
      pwd(30type value 'sapftp1234a',
      host(64type value '10.12.38.45',
      ftp_pwd(30type c,
      dest like rfcdes-rfcdest value 'SAPFTPA',
      key type value 26101957,
      slen type i,
      hdl type i,
      compress type value 'N' ,
      cc_ascii(5value 'ascii',
      ftpcommand(100type c.  "FTP㏑.

data: begin of result occurs 0,
      line(100type c,
      end of result.

parameters : ftp_dir like epsf-epsdirnam default '\backup',
             sap_dir like epsf-epsdirnam default 'e:\FTP\PLM\'.

slen strlenpwd ).

call function 'HTTP_SCRAMBLE'
  exporting
    source      pwd
    sourcelen   slen
    key         key
  importing
    destination ftp_pwd.

call function 'FTP_CONNECT'
  exporting
    user            user
    password        ftp_pwd
    host            host
    rfc_destination dest
  importing
    handle          hdl.

if sy-subrc 0.
  write:'RFC Connection Sucessful', sy-subrc.
else.
  write:'RFC Connection Fails', sy-subrc.
  check 2.
endif.

*---------->
data: i_filenm(60),
      st_comm(250),
      wk_lpath(60),
      tb_comm like table of st_comm.

refresh: tb_comm.
clear:   st_comm.

concatenate 'lcd' sap_dir into st_comm separated by space.
append st_comm to tb_comm.
clear: st_comm.

concatenate 'cd' ftp_dir into st_comm separated by space.
append st_comm to tb_comm.
clear: st_comm.

concatenate 'mput' '*.*' into st_comm separated by space.
append st_comm to tb_comm.
clear: st_comm.

*--------->
data:st_rslt(100type c,
     tb_rslt like table of st_rslt.
call function 'FTP_COMMAND_LIST'
  exporting
    handle        hdl
  tables
    data          tb_rslt
    commands      tb_comm
  exceptions
    command_error 1
    tcpip_error   2.

case sy-subrc.
  when '1'.
    result 'N'.
    write :/(10sy-subrc,
            (10'Command Error'.
  when '2'.
    result 'N'.
    write :/(10sy-subrc,
            (10'Tcpip Error'.
  when others.
    result 'Y'.
endcase.

call function 'FTP_DISCONNECT'
  exporting
    handle hdl.

call function 'RFC_CONNECTION_CLOSE'
  exporting
    destination dest
  exceptions
    others      1.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值