cancel
Showing results for 
Search instead for 
Did you mean: 

Sending/receiving files using SFTP

Former Member
0 Kudos

Hi,

Is there a way to use the Secure File Transfer Protocol (SFTP) in ABAP to send/receive files?

I already used the FTP functionality from the function group SFTP, but I'm honestly not sure whether ABAP also handles the secure version of FTP.

If there is this functionality, please provide me the necessary function modules, ...

Thanks in advance

Bye,

Timo

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Timo,

There is no SFTP in ABAP.But u have FTP in it.For more reference do check on to this links:

http://help.sap.com/saphelp_erp2005/helpdata/en/f1/b4a6bddf3911d18e080000e8a48612/frameset.htm

http://help.sap.com/saphelp_erp2005/helpdata/en/d6/1b9f4099852e54e10000000a1550b0/frameset.htm

Hope this helps u,

Regards,

Nagarajan.

Answers (1)

Answers (1)

Former Member
0 Kudos

FTP functionality woks fine in ABAP. Below is some code which can be used for FTP access to send/receive files.

Initially, get values for the below fields

DATA: l_user(30) TYPE c VALUE <userid>,

l_pwd(30) TYPE c VALUE <password>,

l_host(64) TYPE c VALUE <host string>,

DATA: l_slen TYPE i,

l_error,

l_pwd(30) TYPE c.

CONSTANTS: c_dest TYPE rfcdes-rfcdest VALUE 'SAPFTP',

c_key TYPE i VALUE 26101957.

  • connect to ftp server

l_pwd = p_pwd.

l_slen = STRLEN( l_pwd ).

CALL FUNCTION 'HTTP_SCRAMBLE'

EXPORTING

SOURCE = l_pwd

sourcelen = l_slen

key = c_key

IMPORTING

destination = l_pwd.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

text = 'Connect to FTP Server'.

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

user = l_user

password = l_pwd

host = l_host

rfc_destination = c_dest

IMPORTING

handle = w_hdl

EXCEPTIONS

OTHERS = 1.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CLEAR : w_outfile, w_file_count.

concatenate <directory> <filename> to field.

MOVE field to w_outfile.

PERFORM download_to_ftp TABLES <int'table>

USING w_outfile.

FORM download_to_ftp TABLES it_tab

USING l_string TYPE char64.

CALL FUNCTION 'FTP_R3_TO_SERVER'

EXPORTING

handle = w_hdl

fname = l_string

character_mode = 'X'

TABLES

text = it_tab[]

EXCEPTIONS

tcpip_error = 1

command_error = 2

data_error = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4

RAISING invalid_output_file.

ENDIF.

Above is used to send.

For receiving use

CALL FUNCTION 'FTP_SERVER_TO_R3'

EXPORTING

handle = w_hdl

fname = l_string

character_mode = 'X'

TABLES

text = it_tab[]

EXCEPTIONS

tcpip_error = 1

command_error = 2

data_error = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4

RAISING invalid_output_file.

ENDIF.

Hope this will help U.

Pl. award appropriate points.

Former Member
0 Kudos

Hi Ramesh,

thanks for your answer. I'm looking for SFTP-functionality, and I already received the answer that there's nothing in ABAP.

I already know how FTP works in ABAP, thanks.

Kind regards,

Timo