Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Saving a File in FTP using DSN or FTPCOMMAND

Former Member
0 Likes
1,532

Hi,

I'm trying to save a file to a remote location in the background using ABAP.

I tried DSN. This didnt work as it writes only to application server SAPUSERS directory.

I tried FTPCONNECT and FTPCOMMAND but getting an error connecting to FTP. (connection failed)

Is it possible to write a file to a remote location in the background using ABAP.

I use a VPN gateway to connect to the remote server (location where file are to be saved) and SAP as well.

Appreciate your help.

Thanks,

Sri

Hi,

For UNC path , The job server needs to run under an account that has permissions to the UNC path that you are trying to schedule. By default, the services are running under a machine account that will likely not have access to the UNC path.

The Universal Naming Convention is a way to identify a shared file in a computer without having to specify (or know) the storage device it is on. In Windows, the UNC name format is:


servername\sharename\path\filename

Please check above.

Thanks and Regards,

P.Bharadwaj

7 REPLIES 7
Read only

Former Member
0 Likes
1,212

Hi,

Try using below logic :

Use 'FTP_CONNECT' which is used to work with FTP server in ABAP.

Afetr connection is established now set path on the FTP server. The path where the file is stored on the FTP server. Using this path we will build a command and pass it to the function module FTP_COMMAND.

Use 'FTP_DISCONNECT' to disconnect to FTP server and 'RFC_CONNECTION_CLOSE' to close RFC connection.

Use of the function module FTP_R3_TO_SERVER would copy the contents from an internal table on the FTP server.

Please revert for further Qs

Thanks and Regards,

P.Bharadwaj

Read only

0 Likes
1,212

Hi Bharadwaj,

'FTP_CONNECT' itself is failing for me.

I'm using FTP login. I'm not sure if am doing something wrong here or if something wrong in the configuration.

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

*-- Your SAP-UNIX FTP user name (case sensitive)

USER = '<Domain-name>\<userid>' "FTP Domain name and userid

PASSWORD = MC_PASSWORD

*-- Your SAP-UNIX server host name (case sensitive)

HOST = '<Remote machine IP>' "FTP server name/IP

RFC_DESTINATION = 'SAPFTP'

IMPORTING

HANDLE = MI_HANDLE

EXCEPTIONS

NOT_CONNECTED = 1

OTHERS = 2.

Thanks,

Sri

Edited by: Sri on Jul 19, 2010 10:04 AM

Read only

0 Likes
1,212

Hi,

Please use HTTP_SCRAMBLE' FM before 'FTP_connect" as follows :

*-- FTP_CONNECT requires an encrypted password to work

CALL FUNCTION 'HTTP_SCRAMBLE'

EXPORTING

SOURCE = password

sourcelen = lv_len

key = lv_key

IMPORTING

destination = password.

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

user = ftp_user

password = password

  • ACCOUNT =

host = host

rfc_destination = 'SAPFTP'

IMPORTING

handle = lv_handle

EXCEPTIONS

not_connected = 1

OTHERS = 2.

Also note that FTP_USER contains the user name of the FTP server, PASSWORD contains the scrambled password received from 'HTTP_SCRAMBLE'. HOST contains the name of server.

Thanks and Regards,

P.Bharadwaj

Read only

0 Likes
1,212

Thanks.

I did use http_scramble before FTP_CONNECT. ftp server, username and password (scramble) are used correctly too.

I was wondering if I need anything else on SAP side in order FTP_CONNECT to work.

I've tested FTP programs. RSFTP001passed but RSFTP002 is failing

Thanks,

Sri

Read only

0 Likes
1,212

Hi,

Please check RFC connection using transaction SM59.Also try using SAPFTPA .

Thanks and Regards,

P.Bharadwaj

Read only

0 Likes
1,212

Hi Bharadwaj,

I realized that FTP_CONNECT takes only ftp locations. I'm using a UNC path that might be the reason for this error.

Is there a way to write/read files from a remote network folder using UNC path?

Thanks,

Sri

Read only

0 Likes
1,212

Hi,

For UNC path , The job server needs to run under an account that has permissions to the UNC path that you are trying to schedule. By default, the services are running under a machine account that will likely not have access to the UNC path.

The Universal Naming Convention is a way to identify a shared file in a computer without having to specify (or know) the storage device it is on. In Windows, the UNC name format is:


servername\sharename\path\filename

Please check above.

Thanks and Regards,

P.Bharadwaj