Application Development 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: 

Problem while sending file from SAP to FTP server

Former Member
0 Kudos

Hi Friends,

As per my requirement i am sending CSV file to a third party FTP server.

First i need to check the file if it is there in the FTP or not, if it is not present then we put the file in to the FTP server.

For this logic first we connect from SAP to FTP using FTP connect Function module.

Then we get into the desired directory by passing command to ftp by FTP command Function module

Then i check for the file using the same FTP command function module.

In the command i pass" ls c90909.csv "

But my problem is if the file is not present in the FTP it is not giving me error "550 permission denied" rather it is giving me

ls c90909.csv

200 command okay

150 opening ASCII mode data connection for file list

226 Transfer complete. 0 bytes transfered. 0 bps.

Please help

Thanks Regards,

Sandipan jena

6 REPLIES 6

brad_bohn
Active Contributor
0 Kudos

The 'ls' ftp command with a filename does not detect the presence of the file; it outputs the contents of the remote directory to that file. The response is correct...

Clemenss
Active Contributor
0 Kudos

Hi sandipan jena,

just scan th output of ls c90909.csv. If there is no c90909.csv then the file does not exist.

Therte is no reason at all for error "550 permission denied" .

Regards,

Clemens

Former Member
0 Kudos

Hi ,

But when ever we go to the command mode and try to get the file if the file is not present it gives the " 550 permiission denied".

Actualy i am checking the value of sy-subrc if it is not zero i am puting the file into the ftp server.

So for that this message in necessary what i think.

I have checked with my team they have given me read write permission.

Do you have any other way??

Sandipan jena

Former Member
0 Kudos

if you are using a command line console, try type "ls" command, if there are some files, the command should show you a list of file names, if not, this a permissions problem

there's no reason at all, that the message 550 permission denied comes from a not existing file.

i suggest you to contact basis or server administrator to fix this issue.

example

in command line using windows 7 ftp service on my computer, i executed a set of commands to show you how a the system messages are displayed and what are you expecting to handle in your own code.

ftp> pwd

257 "/borrar/pruebaftp" is current directory.

This command is for show current directory.

ftp> ls -l

200 PORT command successful.

125 Data connection already open; Transfer starting.

226 Transfer complete.

i tried a list of files ( ls command ) and nothing but system messages are shown

ftp> mkdir somedir

257 "somedir" directory created.

i made a directory on current working directory

ftp> ls -l

200 PORT command successful.

125 Data connection already open; Transfer starting.

drwxrwxrwx 1 owner group 0 Apr 4 13:24 somedir

226 Transfer complete.

ftp: 68 bytes recibidos en 0.00segundos 34.00a KB/s.

here again a list of files, with -l option to show more details about the file or directory

ftp> ls

200 PORT command successful.

125 Data connection already open; Transfer starting.

somedir

226 Transfer complete.

ftp: 9 bytes recibidos en 0.01segundos 1.80a KB/s.

again a list of files whitout options

this should help to catch exactly the same messages output on abap code using standard FM. in table data

good luck

Former Member
0 Kudos

using de ftp_command FM with command "ls -l" you can loop at data table looking for the file name, maybe using regular expressions

if you find the row with such name, then the files exists on server.

the message 500 permission denied is for ( as self meaning ) writing o reading permission on the current directory.

good luck

marcin_cholewczuk
Active Contributor
0 Kudos

Hi,

Other approach would be if file is not so big than just download it with 'mget' command. If it's not there then you'll get an error.

I'm wondering how would ftp react if you would try to create directory with the same name as file (with command 'mkdir'). If it's not possible for both file and directory to have the same name you can also use it (command to later delete directory 'rmdir').

Best regards

Marcin Cholewczuk