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: 

ABAP FTP_CONNECT with anonymous access

flow82er
Explorer
0 Kudos
870

Hi,

I try to connect to an FTP server using ABAP. I want to connect with user/password, so I use the user anonymous with an email-Adresse as password.

The code looks like the following:

 

call function 'FTP_CONNECT'
  exporting
    user            = 'anonymous'
    password        = 'my@email.com'
    host            =  '95.31.30.236'
    rfc_destination = 'SAPFTP'
  importing
    handle          = hdl.

 

However, I when execute the programm, I get get the error

User anonymous is not allowed on 95.31.30.236.

But connecting to this server server using FileZilla with the same credentials, works well. So anonymous connection is allowed.

 

Any suggestions how to connect via ABAP using anonymous user?

Thx!

 

 

 

 

5 REPLIES 5

RaymondGiuseppi
Active Contributor
0 Kudos
812

Try to use HTTP_SCRAMBLE before FTP_CONNECT

  • Look at sample report RSFTP002 (you can use it to test)

0 Kudos
803

Hi & thx for your answer.

I've already tried this, without success.

In the meantime I've found out that I have to maintain the FTP whitelist via maintenance view SAPFTP_SERVERS_V. After that, the connection worked!

As the next step, I wanted to make directory listing using

CALL FUNCTION 'FTP_COMMAND'
  EXPORTING
    handle  = hdl
    command = 'dir'
  TABLES
    data    = mtab_data
 EXCEPTIONS
   TCPIP_ERROR           = 1
   COMMAND_ERROR         = 2
   DATA_ERROR            = 3
   OTHERS                = 4

This one fails with a COMMAND_ERROR: 502 PORT/EPRT not supported in transparent mode

Any Ideas regarding this one?

0 Kudos
775

Try sending first a FTP command such as 'set passive on'

Sandra_Rossi
Active Contributor
0 Kudos
760

You have to use HTTP_SCRAMBLE for the password.

data: pwd(30) type c,
      key type i value 26101957, "<=== code for FTP
      slen type i,
      scrambled_pwd(60) type c. "<=== must be double length of PWD

slen = strlen( pwd ).
call function 'HTTP_SCRAMBLE'
  exporting
    source      = pwd
    sourcelen   = slen
    key         = key
  importing
    destination = scrambled_pwd.

ulrich_mhrke
Participant
0 Kudos
669

Have a look at SAP note 1605054 (https://me.sap.com/notes/1605054).