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/