Skip to Content
author's profile photo Former Member
Former Member

Sending/receiving files using SFTP

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 06, 2005 at 01:30 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 06, 2005 at 02:13 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.