06-23-2008 8:24 AM
Hi Friends,
We are working on SAP 4.7 system, and have a requirement to SFTP some files from our server to an external server.
We are sending files to many other servers using function module FTP_CONNECT. This FM works where Port 23 is active. But for the new server it has only SSH (22) and HTTPS (443) ports available, so the FTP_CONNECT FM fails. We have tried sending the files from Putty using statement SFTP <ID>@<IP> and it worked.
Does any one know how we can do SFTP from SAP reports? Please note that as per the SAP help I have already tried using FM FTP_CONNECT with HOST_NAME as '<IP> space 22'. But it didnt work.
Waiting for your valuable updates.
Regards,
Rahul
06-24-2008 5:38 PM
Hi,
try and optimize this example:
&----
*& Report ZTESTFTPSAP *
*& *
&----
*& *
*& *
&----
REPORT ZTESTFTPSAP .
data: unixcom like rlgrap-filename. " ...SAP Interface file
data: begin of tabl occurs 500,
line(400),
end of tabl.
data: lines type i.
data: begin of tlines occurs 0,
line(90),
end of tlines.
data: ffile(50) type c.
*----
start-of-selection.
refresh tabl.
refresh tlines.
append 'open ftp.yourserver.com:22' to tlines.
append 'user=anonymous' to tlines.
append 'pwd=pass' to tlines.
append 'cd pub' to tlines.
append 'close' to tlines.
append 'bye' to tlines.
ffile = 'c:\temp\ftp.txt'.
OPEN DATASET ffile FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.
loop at tlines.
transfer tlines to ffile.
endloop.
CLOSE DATASET ffile.
unixcom = 'ftp -s:c:\temp\ftp.txt'.
call 'SYSTEM' id 'COMMAND' field unixcom
id 'TAB' field tabl[].
describe table tabl lines lines.
loop at tabl.
write:/01 tabl-line.
endloop.
skip 2.
if lines = 0.
write:/ 'NO Occurances were found'.
else.
write:/ 'Command was successfully executed' color col_total.
write:/ 'Number of entries in Search' color col_total,
lines color 6.
endif.
06-24-2008 5:38 PM
Hi,
try and optimize this example:
&----
*& Report ZTESTFTPSAP *
*& *
&----
*& *
*& *
&----
REPORT ZTESTFTPSAP .
data: unixcom like rlgrap-filename. " ...SAP Interface file
data: begin of tabl occurs 500,
line(400),
end of tabl.
data: lines type i.
data: begin of tlines occurs 0,
line(90),
end of tlines.
data: ffile(50) type c.
*----
start-of-selection.
refresh tabl.
refresh tlines.
append 'open ftp.yourserver.com:22' to tlines.
append 'user=anonymous' to tlines.
append 'pwd=pass' to tlines.
append 'cd pub' to tlines.
append 'close' to tlines.
append 'bye' to tlines.
ffile = 'c:\temp\ftp.txt'.
OPEN DATASET ffile FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.
loop at tlines.
transfer tlines to ffile.
endloop.
CLOSE DATASET ffile.
unixcom = 'ftp -s:c:\temp\ftp.txt'.
call 'SYSTEM' id 'COMMAND' field unixcom
id 'TAB' field tabl[].
describe table tabl lines lines.
loop at tabl.
write:/01 tabl-line.
endloop.
skip 2.
if lines = 0.
write:/ 'NO Occurances were found'.
else.
write:/ 'Command was successfully executed' color col_total.
write:/ 'Number of entries in Search' color col_total,
lines color 6.
endif.