2008 Mar 12 12:44 PM
Hi,
I'm trying to connect to an external ftp-server via a proxy FTP-server using function ftp_connect.
I'm using the gateway parameters to connect to the proxy, but the function always returns an error saying that the user doesn't have access to the external FTP-server. I know the users and passwords are correct. Is it the correct way to use the gateway parameters? What is the account parameter for?
Thanks,
Wim
Hi,
I'm trying to connect to an external ftp-server via a proxy FTP-server using function ftp_connect.
I'm using the gateway parameters to connect to the proxy, but the function always returns an error saying that the user doesn't have access to the external FTP-server. I know the users and passwords are correct. Is it the correct way to use the gateway parameters? What is the account parameter for?
Thanks,
Wim
2008 Mar 12 12:51 PM
Check below code... It may help U...
DATA: l_slen TYPE i,
l_error,
l_pwd(30) TYPE c.
CONSTANTS: c_dest TYPE rfcdes-rfcdest VALUE 'SAPFTP',
c_key TYPE i VALUE 26101957.
l_error = 0.
connect to ftp server
l_pwd = p_pwd.
l_slen = STRLEN( l_pwd ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = l_pwd
sourcelen = l_slen
key = c_key
IMPORTING
destination = l_pwd.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = 'Connect to FTP Server'.
To Connect to the Server using FTP
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = p_user
password = l_pwd
host = p_host
rfc_destination = c_dest
IMPORTING
handle = w_hdl
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR : w_outfile, w_file_count.
MOVE 'ERC/GLOBALSAP/M_ERC_GLOBALSAP_COACODE' TO w_outfile.
PERFORM download_to_ftp TABLES it_coacode USING w_outfile.
w_file_count = w_file_count + 1.
CLEAR : w_outfile.
To disconnect the FTP
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = w_hdl.
To disconnect the RFC Connection
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = c_dest
EXCEPTIONS
OTHERS = 1.
FORM download_to_ftp TABLES it_tab
USING l_string TYPE char64.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
handle = w_hdl
fname = l_string
character_mode = 'X'
TABLES
text = it_tab[]
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
RAISING invalid_output_file.
ENDIF.
ENDFORM. " download_to_ftp
2008 Mar 12 1:01 PM
Hi Ramesh,
This was not my question. I know how to connect directly to an FTP-server.
My question is how to connect via a proxy-server.
Kr,
Wim
2008 Mar 18 3:34 PM
2008 May 15 5:31 PM
hi wim,
we have the same problem. now - do you have a nice solution?
manually i have transfer data via http-proxy in ftp with total commander - a nice quick ftp-client.
###
IMPORTING
*" VALUE(USER) TYPE C
*" VALUE(PASSWORD) TYPE C
*" VALUE(ACCOUNT) TYPE C OPTIONAL
*" VALUE(HOST) TYPE C
*" VALUE(RFC_DESTINATION) LIKE RFCDES-RFCDEST
*" VALUE(GATEWAY_USER) TYPE C OPTIONAL
*" VALUE(GATEWAY_PASSWORD) TYPE C OPTIONAL
*" VALUE(GATEWAY_HOST) TYPE C OPTIONAL
*" EXPORTING
*" VALUE(HANDLE) TYPE I
*" EXCEPTIONS
*" NOT_CONNECTED
####
the http-proxy in own case runs on port 8080, we have put in parameter gateway_host in this syntax: XXX.XXX.XXX.XXX 8080
Does not work.
may be a problem of rfc-destination and unicode?
saphttpa, saphttp or sapftp and sapftpa
on os in a dos-box ftp with proxy does not work. with sapftp on os i become a connect with following syntax
sapftp>
open XXX.XXX.XXX.XXX 8080
Connected to XXX.XXX.XXX.XXX Port 8080.
hm, why i become this result not in abap.
thx.
christoph
2008 May 16 3:33 PM
hi wim,
the solution is in this dev_ftp tail:
[1992] connect request host : <proxy_host>, user : <user>@<ftp_host>
[1992] Connected to <proxy_host> Port 21.
- NI handle: 1
[1992] FTP server : 220 rev-proxy29 FTP server (Version 1.9.2.2 - 2004/03/30 10:42:46) ready.
[1992] ---> <user>@<ftp_host>
[1992] FTP server : 331 Password required
[1992] ---> *****
[1992] FTP server : 230 user logged in
[1992] ---> TYPE I
[1992] FTP server : 200 Type set to IMAGE.
thanks,
christoph in cooperation with andy
2009 Sep 22 9:18 AM
Hi Christoph,
how do you get this output? What do you pass to the FM 'FTP_CONNECT' to get a connection?
lv_userid =
lv_pwd =
lv_rfcdst = 'SAPFTP'.
lv_host =
lv_rfcgwhost =
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = lv_userid
password = lv_pwd
ACCOUNT =
host = lv_host
rfc_destination = lv_rfcdst
gateway_user =
gateway_password =
gateway_host = lv_rfcgwhost
IMPORTING
handle = lv_handle
EXCEPTIONS
not_connected = 1
OTHERS = 2.
Thanks,
Hubert
2008 May 19 10:04 AM
We were not able to solve this issue. So for specific external FTP-servers the authentication was removed from the proxy and then everything worked fine...
2008 May 19 8:12 PM
ah ok - we have no authentication on the proxy - only authentication on ftp. do you know about sftp (ftp via ssh) - it will be supported from sapftp?
we have a http-proxy with ftp support - that is the right title.
thanks,
christoph
2011 Sep 06 4:38 PM
in my opinion, the proxy settings must be set directly in the destination
2011 Sep 27 10:05 AM
Hello François,
I'm trying to access an FTP Server via a proxy server as well - but it doesn't seem to work.
I can connect to that FTP Server via the same proxy with FileZialla so I know the users and PWDs are working.
How can I provide the proxy information (host, user and PWD) within the RFC connection - or what do you mean by destination?
The FTP trace (run program RSFTP001) gives the following result:
trc file: "dev_ftp", trc level: 2, release: "700"
Tue Sep 27 10:37:26 2011
[7299248] sccsid:@(#) $Id: //bas/700_REL/src/krn/ftp/ftpmain.c#17 $ SAP
@(#) $Id: //bas/700_REL/src/krn/ftp/ftp.c#4 $ SAP
@(#) $Id: //bas/700_REL/src/krn/ftp/ftpcmd.c#4 $ SAP
sapftp.ini file path : /usr/sap/D2E/DVEBMGS10/exe/sapftp.ini
SAPFTP Passive mode set to = 0
[7299248] FTP Start : argc - 6 a0 - /usr/sap/D2E/DVEBMGS10/exe/sapftp
g56e sapgw10 74691815 CPIC_TRACE=2 IDX=1
[7299248] RFC Version 700
[7299248] Install server functions
[7299248] Call RfcAccept
[7299248] Enter RfcDispatch loop
[7299248] Partner codepage 4102
[7299248] connect request host : ftp.host.com , user : FTPUser
[7299248] gateway host : proxy.lan.net , user : ProxyUser
[7299248] Connected to proxy.lan.net Port 21.
- NI handle: 1
[7299248] FTP server : 220 Proxy FTP Service
[7299248] > USER ProxyUser
[7299248] FTP server : 331 Enter password.
[7299248] > *****
[7299248] FTP server : 530-User Access denied.
530-
530-Usage: USER username@proxyusername@hostname
530 PASS password@proxypassword
[7299248] FTP disconnect - NI handle : 1
[7299248] > QUIT
[7299248] FTP server : 221 Service closing control connection.
[7299248] FTP StopIn my coding I scrambled both PWDs with FM 'HTTP_SCRAMBLE' using key '26101957'.
I tried as well setting the parameter user to (using the scrambeld PWDs) but this gives the same resulst.
Here's a part of my code
REPORT zz_test_ftp.
PARAMETERS: user(50) TYPE c LOWER CASE,
pwd(60) TYPE c LOWER CASE,
host(64) TYPE c LOWER CASE,
gw_user(30) TYPE c LOWER CASE,
gw_pwd(30) TYPE c LOWER CASE,
gw_host(30) TYPE c LOWER CASE,
cmd1(80) TYPE c LOWER CASE,
cmd2(80) TYPE c LOWER CASE,
cmd3(80) TYPE c LOWER CASE,
dest LIKE rfcdes-rfcdest DEFAULT 'SAPFTPA',
compress TYPE c DEFAULT 'N'.
DATA: hdl TYPE i,
key TYPE i VALUE 26101957,
slen TYPE i.
DATA: BEGIN OF result OCCURS 0,
line(100) TYPE c,
END OF result.
SET EXTENDED CHECK OFF.
slen = STRLEN( pwd ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = pwd
sourcelen = slen
key = key
IMPORTING
destination = pwd.
slen = STRLEN( gw_pwd ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = gw_pwd
sourcelen = slen
key = key
IMPORTING
destination = gw_pwd.
"concatenate user '@' gw_user '@' host into USER.
"concatenate pwd '@' gw_pwd into PWD.
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = user
password = pwd
account = user
host = host
rfc_destination = dest
gateway_user = gw_user
gateway_password = gw_pwd
gateway_host = gw_host
IMPORTING
handle = hdl.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |