Skip to Content
Technical Articles

How To Transfer Files Into SFTP using ABAP Program

Introduction to SFTP:

SFTP – Secure File Transfer Protocol

This creates an encrypted channel between SAP and the targeted system SFTP. In cloud environment most of the client follows this concept to store files in to SFTP from Integration perspective.


While transferring files from SAP ECP ( Employee Central Payroll ) to any 3rd party vendor OR to any internal application , SAP has given this Secure File Transfer Protocol . Mostly used in ECP and SuccessFactors environment.

Brief recall of other file transfer techniques :

A. File transfer to SAP from local system using CL_GUI_FRONEND_SERVICES. Method: GUI_DOWNLOAD / GUI_UPLOAD.

B. File Transfer using LSMW.

C. File transfer to SAP Application Server ( AL11 ) using DATA SET concept .


OPEN DATASET Filename FOR access IN mode [position]
[error handling] .

Steps To Transfer File From SAP To SFTP Using HTTP Connection:

Step 1: Step up HTTP RFC connection

Make sure there must be a RFC exist (check in SM59 under HTTP connection to External Server) Connection Type – ” G  ” (HTTP Connection to External Server) . In target host of technical settings provide the correct URL (This URL is to access SFTP server) .

Step 2: Create complete file name 

It must include your file destination and file name separated by “/ “.

Step 3: Write your ABAP code to make connection to RFC using CL_HTTP_CLIENT

Method: CREATE_BY_DESTINATION  – Here connection will be establish between SFTP and Backend ABAP Program .

Collect reference of IF_HTTP_CLIENT ( Ex. Ref_client type ref to IF_HTTP_CLIENT )

Step 4 : Set the URI ( Set the File Detail )

Class : CL_HTTP_UTILITY , Method : SET_REQUEST_URI – pass above received connection details with uri ( file name ).

Step 5 : Set Header Fields

Use Ref of IF_HTTP_CLIENT ( ref_client ) , Method : REQUEST  and SET_HEADER_FIELD

Parameters :

A . ~request_method : DELETE/PUT/GET ( Depending on requirement ).

B. ~server_protocal : HTTP/1.0

C. content_type : Pass the whole content in xstring format

Step 6: Put file in to SFTP

Use Ref of IF_HTTP_CLIENT ( ref_client ) , Method : SET_DATA

Step 7: Read file from SFTP

Use Ref of IF_HTTP_CLIENT ( ref_client ) , Method : GET_DATA

Step 8: send/receive via HTTP Sever

Use Ref of IF_HTTP_CLIENT ( ref_client ) , Method : SEND and Method : RECEIVE

Step 9: Close Connection 

Never forget to close your connection after successful response.

************************SHARE AND LEARN************************

You must be Logged on to comment or reply to a post.
    • Hello Sandra,

      The main objective is to transfer data from SAP to SFTP server using HTTP class .

      We can use CL_HTTP_CLIENT class / IF_HTTP_CLIENT interface in OO ABAP to transfer data from SAP to SFTP ( which is a secure server provided by SAP for cloud Application ).


      • Hi Biswajit,

        SuccessFactors SFTP server happens to provide REST API in addition to SFTP service and you have used the REST API in your program. Not all SFTP servers provide REST API.

        Thank you for sharing regardless. Looking forward to more content.




  • Hi Biswajit,

    Do you know how to get the file list under a specified folder? and do you know how to use a wildcard to get the files? e.g, *.xml will return all file suffixed with .xml, like file1.xml, file2. I’m asking this because I have a requirement that I don’t know the complete filename, what I know is the only folder path. Thanks.