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

FTP to remote server

Former Member
0 Likes
973

Hi,

I want to connect to a remote system, which i don't know it is ftp server or normal machine, but i have IP address of the same through which i can access it. my doubt is

what will be the host name in the ftp_connect fm and what is rfc destination. when i give IP address of that machine in the host and rfc destination as SAPFTP it is showing connection failed. i have access for that system.

please suggest.

1 ACCEPTED SOLUTION
Read only

RahulKeshav
Active Contributor
0 Likes
773

Try this....

g_dlen = STRLEN( p_pwd ).

***Below Function module is used to Encrypt the Password

CALL FUNCTION 'HTTP_SCRAMBLE'

EXPORTING

SOURCE = p_pwd "Actual password

sourcelen = g_dlen

key = c_key

IMPORTING

destination = g_dpwd. "Encyrpted Password

***Connects to the FTP Server as specified by user

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

text = 'Connecting to FTP Server'.

*Below function module is used to connect the FTP Server.

*It Accepts only Encrypted Passwords.

*This Function module will provide a handle to perform different

*operations on the FTP Server via FTP Commands.

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

user = p_user

password = g_dpwd

host = p_host

rfc_destination = c_dest

IMPORTING

handle = g_dhdl

EXCEPTIONS

not_connected = 1

OTHERS = 2.

IF sy-subrc NE 0.

MESSAGE s000 WITH 'Error in Connection'(250).

ELSE.

MESSAGE s000 WITH 'FTP Connection is Opened'(251).

ENDIF.

***do what ever you want to do.)********

read FTP

write FTP

***To Disconnect the FTP Server

CALL FUNCTION 'FTP_DISCONNECT'

EXPORTING

handle = g_dhdl.

***To Disconnect the Destination

CALL FUNCTION 'RFC_CONNECTION_CLOSE'

EXPORTING

destination = c_dest

EXCEPTIONS

OTHERS = 1.

thnx

Rahul

Hi,

I want to connect to a remote system, which i don't know it is ftp server or normal machine, but i have IP address of the same through which i can access it. my doubt is

what will be the host name in the ftp_connect fm and what is rfc destination. when i give IP address of that machine in the host and rfc destination as SAPFTP it is showing connection failed. i have access for that system.

please suggest.

4 REPLIES 4
Read only

Former Member
0 Likes
773

Have you tried this?


  CALL FUNCTION 'FTP_CONNECT'
    EXPORTING
      user            = l_username
      password        = l_password
      host            = l_ipadresss
      rfc_destination = 'SAPFTPA'
    IMPORTING
      handle          = p_handle
    EXCEPTIONS
      not_connected   = 1
      OTHERS          = 2.

Remember, RFC Destination is usually something you have to configure on SM59. That SAPFTPA should have been configured by your system administrator (it's a simple TCP/IP destination calling server program "sapftp"). The IP address of the FTP server however doesn't need to be configured on SM59 thought.

Regards,

Sergio

Edited by: Sérgio Oliveira on Aug 3, 2009 2:56 PM

Read only

Former Member
0 Likes
773

Hi Kranthi

Have a look in below wiki on FTP connectivity,you will get all info regarding your query

https://wiki.sdn.sap.com/wiki/display/Snippets/ABAPsolutiontoimplementFTP+transactions

Thanks and Regards,

Syfulla

Read only

Former Member
0 Likes
773

Hi Kranthi,

Host name will be: The logical name of the remote FTP server.

Read only

RahulKeshav
Active Contributor
0 Likes
774

Try this....

g_dlen = STRLEN( p_pwd ).

***Below Function module is used to Encrypt the Password

CALL FUNCTION 'HTTP_SCRAMBLE'

EXPORTING

SOURCE = p_pwd "Actual password

sourcelen = g_dlen

key = c_key

IMPORTING

destination = g_dpwd. "Encyrpted Password

***Connects to the FTP Server as specified by user

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

text = 'Connecting to FTP Server'.

*Below function module is used to connect the FTP Server.

*It Accepts only Encrypted Passwords.

*This Function module will provide a handle to perform different

*operations on the FTP Server via FTP Commands.

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

user = p_user

password = g_dpwd

host = p_host

rfc_destination = c_dest

IMPORTING

handle = g_dhdl

EXCEPTIONS

not_connected = 1

OTHERS = 2.

IF sy-subrc NE 0.

MESSAGE s000 WITH 'Error in Connection'(250).

ELSE.

MESSAGE s000 WITH 'FTP Connection is Opened'(251).

ENDIF.

***do what ever you want to do.)********

read FTP

write FTP

***To Disconnect the FTP Server

CALL FUNCTION 'FTP_DISCONNECT'

EXPORTING

handle = g_dhdl.

***To Disconnect the Destination

CALL FUNCTION 'RFC_CONNECTION_CLOSE'

EXPORTING

destination = c_dest

EXCEPTIONS

OTHERS = 1.

thnx

Rahul