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

Error while connecting to FTP

Former Member
0 Likes
1,759

Hello all,

I am using the function module FTP_CONNECT to connect to a FTP site. I am providing the correct IP address of the host, the user ID and password. Before passing all these parameters to the function module, I am also calling 'AB_RFC_X_SCRAMBLE_STRING' to encrypt the password. But I am getting an error which says the user has no authorization to connect to the ftp site.

The IP address of the host is correct, and the FTP site exists.

Can anybody help me out with this problem? Even if this might not be an ABAP problem I would appreciate suggestions that could direct me to the exact problem.

Thanks in advance,

Swaminath G

4 REPLIES 4
Read only

Former Member
0 Likes
1,080

Hi,

I think you do not have Authorization for that one, make sure whether you have the correct Authorization to conect FTP.

<b>see the example program:-</b>

REPORT ZFTPSAP LINE-SIZE 132.

DATA: BEGIN OF MTAB_DATA OCCURS 0,
LINE(132) TYPE C,
END OF MTAB_DATA.

DATA: MC_PASSWORD(20) TYPE C,
MI_KEY TYPE I VALUE 26101957,
MI_PWD_LEN TYPE I,
MI_HANDLE TYPE I.

START-OF-SELECTION.

*-- Your SAP-UNIX FTP password (case sensitive)
MC_PASSWORD = 'password'.

DESCRIBE FIELD MC_PASSWORD LENGTH MI_PWD_LEN.

*-- FTP_CONNECT requires an encrypted password to work
CALL 'AB_RFC_X_SCRAMBLE_STRING'
     ID 'SOURCE' FIELD MC_PASSWORD ID 'KEY' FIELD MI_KEY
     ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD MC_PASSWORD
     ID 'DSTLEN' FIELD MI_PWD_LEN.

CALL FUNCTION 'FTP_CONNECT'
     EXPORTING
*-- Your SAP-UNIX FTP user name (case sensitive)
       USER            = 'userid'
       PASSWORD        = MC_PASSWORD
*-- Your SAP-UNIX server host name (case sensitive)
       HOST            = 'unix-host'
       RFC_DESTINATION = 'SAPFTP'
     IMPORTING
       HANDLE          = MI_HANDLE
     EXCEPTIONS
       NOT_CONNECTED   = 1
       OTHERS          = 2.

CHECK SY-SUBRC = 0.

CALL FUNCTION 'FTP_COMMAND'
     EXPORTING
       HANDLE = MI_HANDLE
       COMMAND = 'dir'
     TABLES
       DATA = MTAB_DATA
     EXCEPTIONS
       TCPIP_ERROR = 1

       COMMAND_ERROR = 2
       DATA_ERROR = 3
       OTHERS = 4.

IF SY-SUBRC = 0.
  LOOP AT MTAB_DATA.
    WRITE: / MTAB_DATA.
  ENDLOOP.
ELSE.
* do some error checking.
  WRITE: / 'Error in FTP Command'.
ENDIF.

CALL FUNCTION 'FTP_DISCONNECT'
     EXPORTING
       HANDLE = MI_HANDLE
     EXCEPTIONS
       OTHERS = 1.    

Regards

Sudheer

Read only

Former Member
0 Likes
1,080

Hi,

if you have access to remote system login to it with

userid . login is successful than there may be problem

in your code or else check authorization for the

remote system.

also check wheter RFC destination exist in sm59 transaction else create and test connect .

CALL FUNCTION 'FTP_CONNECT'

EXPORTING USER = USER PASSWORD = PWD HOST = HOST

<b> RFC_DESTINATION = DEST</b> IMPORTING HANDLE = HDL

EXCEPTIONS NOT_CONNECTED = 1

OTHERS = 2.

IF SY-SUBRC = 1.

MESSAGE ID SY-MSGID TYPE 'I' NUMBER SY-MSGNO "SY-MSGTY

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

EXIT.

ENDIF.

regards

amole

Read only

0 Likes
1,080

Hi

I tried logging in to the remote system. But I was not able to do so. How can I check the authorization for the remote system? Is there anything in particular I should do?

Read only

0 Likes
1,080

Hello,

Can anyone help me with suggestions for this problem? I am unable to connect to the FTP site. It says user has no authorization.

RFC destination is transaction SM59 is created and the connection is also tested.

This is the code I am using :

CALL 'AB_RFC_X_SCRAMBLE_STRING'

ID 'SOURCE' FIELD ftp_pwd ID 'KEY' FIELD key

ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD ftp_pwd

ID 'DSTLEN' FIELD dstlen.

  • Connect zum FTP

WRITE: / 'Connecting to FTP-Server'.

SKIP 1.

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

user = ftp_user

password = ftp_pwd

host = ftp_host

rfc_destination = 'SAPFTPA'

IMPORTING

handle = hdl

EXCEPTIONS

not_connected = 1.

IF sy-subrc <> 0.

SKIP 1.

WRITE: / 'Connection not successful ! Abort'.

EXIT.

ENDIF.

I am getting sy-subrc <> 0. Hence the message 'Connection not successful ! Abort'.

I realize it might not be an ABAP problem, but could be a problem with the FTP settings. If so, is it possible to find out exactly what the problem is?

Thanks in advance,

Swaminath G