从FTP server读取数据(1)

data: host(100) type c value '',

        user(20) type c,

        pwd(30) type c,

        lcase(1) type c,

        lcustomer(20) type c.

  data: lftpfile(100) type c,

        tmpc(255) type c,

        lbakfile(100) type c.

  data: begin of commands occurs 0,

       cmd(100) type c,

      end of commands.

  data: begin of data occurs 0,

      line(255) type c,

      end of data.

  data: result like data occurs 0.

  data: hdl type i,

        key type i value 26101957,

        dstlen type i,

        nlen type i,

        l_flag(1) type c.

 

host = 'ftp://10.194.1.22/'.  “必须要是这样的格式

user = 'it'.

pwd = 'it'.

translate user to lower case.

translate pwd to lower case.

lftpfile = 'EDI'.

 search host+6 for '/'.

  host = host+6(sy-fdpos).

*FTP connect

  describe field pwd length dstlen.

  call 'AB_RFC_X_SCRAMBLE_STRING'

    id 'SOURCE'      field pwd    id 'KEY'         field key

    id 'SCR'         field 'X'    id 'DESTINATION' field pwd

    id 'DSTLEN'      field dstlen.

  call function 'FTP_CONNECT'

    exporting

      user            = user

      password        = pwd

      host            = host

      rfc_destination = 'SAPFTPA'

    importing

      handle          = hdl

    exceptions

      not_connected          = 1

      others                 = 2.

*Get file list

  call function 'FTP_COMMAND'

       exporting

            handle        = hdl

            command       = 'cd /'  “ /表示进入当前的目录

       tables

            data          = data

       exceptions

            tcpip_error   = 1

            command_error = 2

            data_error    = 3

            others        = 4.

  refresh:data.

  call function 'FTP_COMMAND'

       exporting

            handle        = hdl

            command       = 'ls'   “ LS 表示显示当前目录下的文件内容

       tables

            data          = data

       exceptions

            tcpip_error   = 1

            command_error = 2

            data_error    = 3

            others        = 4.



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

转载于:http://blog.itpub.net/15117617/viewspace-548788/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值