SAP系统中连接FTP服务器需要配置表SAPFTP_SERVERS,在这个表中添加ftp服务器及端口,然后使用如下代码连接ftp服务器
constants cons_key type i value 26101957.
data:lv_pwd(64) type c,
lv_handle type i,
lv_length type i,
lv_pwdlen type i.
lv_pwd = is_ftpinfo-password.
lv_pwdlen = strlen( lv_pwd ).
*密码加密
call function 'HTTP_SCRAMBLE'
exporting
source = lv_pwd
sourcelen = lv_pwdlen
key = cons_key
importing
destination = lv_pwd.
do 3 times." 连接三次,以为一次可能会不成功
* 连接FTP服务器
call function 'FTP_CONNECT'
exporting
user = is_ftpinfo-username
password = lv_pwd "PASS WORD
host = is_ftpinfo-host
rfc_destination = 'SAPFTPA' "DEFAULT
importing
handle = ev_handle
exceptions
not_connected = 1
others = 2.
if sy-subrc = 0.
exit.
endif.
enddo.
rv_subrc = sy-subrc.