*&-----------------------------------------------------------------*
*& Form send_data_form
*&----------------------------------------------------------------*
FORM. send_data_form.
data: filename1(100) type c value 'zrpp0027.txt',
filename2(100) type c,
myline(255) type c,
sumln type i.
data: p_cor type i value '1000'.
sort itab by werks .
loop at itab. “开始循环内表itab内容
if sumln >= p_cor.
wait up to 1 seconds.
concatenate 'EDI' '.txt' into filename2.
concatenate 'put' filename1 filename2 into commands-cmd separated by space.
“使用PUT语句来产生的text文件放置到Ftp server
append commands.
perform. ftpc.
perform. close_ftp.
clear sumln.
endif.
if sumln = 0.
perform. conn_ftp.
open dataset filename1 in text mode for output.
endif.
clear myline.
concatenate itab-werks itab-matnr into myline separated by '|'.
transfer myline to filename1.
“使用transfer语句将内表数据写入到text file中
sumln = sumln + 1.
endloop.
if sumln > 0.
close dataset filename1.
wait up to 1 seconds.
concatenate 'EDI' 'Plant' '.TXT' into filename2.
concatenate 'put' filename1 filename2
into commands-cmd separated by space.
append commands.
perform. ftpc.
perform. close_ftp.
endif.
ENDFORM.
*-----------------------------------------------------------------*
* FORM. ftpc *
*-----------------------------------------------------------------*
form. ftpc.
loop at commands.
if commands-cmd ne ' '.
call function 'FTP_COMMAND'
EXPORTING
handle = hdl
command = commands-cmd
TABLES
data = result
EXCEPTIONS
command_error = 1
tcpip_error = 2.
loop at result.
write: / result-line.
if result cs 'error'.
subrc = 4.
exit.
endif.
endloop.
refresh result.
if sy-subrc <> 0.
exit.
endif.
endif.
endloop.
clear commands.
refresh commands.
endform. "ftpc
*------------------------------------------------------------------*
* FORM. close_ftp *
*-----------------------------------------------------------------*
FORM. close_ftp.
call function 'FTP_DISCONNECT'
EXPORTING
handle = hdl.
endform. .
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/15117617/viewspace-548792/ ,如需转载,请注明出处,否则将追究法律责任。