Skip to Content
Author's profile photo Former Member

SFTP – Connection From SAP ABAP – Findings

Hello ,

I am posting this blog to list out my findings of the possibility of Connecting to a server enabled with  SFTP from a Abap program.

I have been given this requirement from my company that i create a report and transfer it to a server which has been changed from normal FTP to SFTP.

In my previous blogs i have already listed the process of using Function Modules to transfer using normal FTP.

I hope this blog helps people understand the limitations of sap abap in using sftp

SAP ABAP has the Functionality to write/Read on FTP server, but there is no functionality in ABAP to read /Write on SFTP server. The code will not work with SFTP server .


Please refer to  SAP Note 795131 – FAQ: How to make Secure FTP communication with SAPFTP.


SAP recommendations

Sap’s recommendation to read/write to SFTP server is by using PI (Process Integration) solution.

Option 1


Server side scripting commands to write to SFTP server from SAP Application Server with the help of an open Source FTP client (WinSCP).I was able to write the script for this in a notepad .


option batch abort

option confirm off

open sftp://username:password@192:192:192:192:9952   { where is the server address and 9952 is the port number }

put F:\check.txt  { This is a local file i created that can be transferred to check the put statement}



Note : If you want to test this code above please install WinSCP and open . Type the code step by step and you will connect and put the file.

The challenge here was that i replicate this using External Commands in SM69 in SAP .So i got to it but the issue here was our system needed some upgrades from a Basis point of view where enabling of External Commands was possible. This is how far i got .

Note : If any one who reads this blog has implemented External Commands from SAP to transfer SFTP please share .

Option 2

Secure File Transfer Protocol (SFTP) can be achieved using SSH (Secure Socket Shell

The flow of the data goes as follows:

  1. Firstly the SSH (client local/daemon local) is configured as per the Vendors instructions.
  2. The SSH client is installed to the client system while the SSH daemon is installed to the FTP server.
  3. The data is sent from SAPFTP to the local port of the SSH client and this makes the data secure (encrypts the data).
  4. Then the SSH client sends this data to the SSH server daemon which decrypts the data and forwards the data to the FTP server.

SSH can be configured for both Active and Passive mode of FTP communication.


There is no straight forward method to transfer to a SFTP server .

Thank you .

Please do post comments and feedback to help me improve my content.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Nelis Lamprecht
      Nelis Lamprecht

      Option 3

      Use SCP to copy files from one server to another. You can setup SSH public key authentication between the two servers so no password is required but the connection is still secured. If the server you are copying to is Windows based you can use CYGWIN to run an SSH service.

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Was hoping for found an easy solution, but I guess no such luck... But thanks anyway for sharing your findings!

      We've had to do an SFTP transfer for just one interface and came up with a very primitive solution of extracting the files to the SAP application server, as usual, and running a scheduled script outside of SAP to get the files and SFTP them. Our limitations were: 1) no in-house Basis support; 2) SAP server runs on Linux; 3) SFTP server was not ours; 4) it was a rather low-priority project, didn't have much time to invest.

      We have no plans or desire or even a need to run PI, so it'd be very helpful if this was available in standard SAP, just like regular FTP.

      Author's profile photo Former Member
      Former Member

      If you have control over both transport ends, you can configure a SSH tunnel and use plain FTP on top of it. No changes are required on the application layer.

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Thanks, Samuli! Unfortunately in our case it was exactly the problem that we didn't control the other end - they just gave us a login and we had to figure out how to get the files there.

      Author's profile photo Former Member
      Former Member


      Hello Jelena,

      I am also having same requirement and did you find solution?


      Thanks and Regards,


      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      We didn't find anything much better. In another system we are running a script that does all the SFTP work as a step in the background job. It's slightly better than running the script outside of SAP since any messages appear in the job log. But still a simpler solution, like for FTP, would be preferable.

      Author's profile photo Former Member
      Former Member

      Thank you very much.

      if you are ok,could you please provide the script used for sftp .




      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      I didn't write the script so can't do, sorry. The script language would be specific to your OS though and you could just look up the commands online. Or ask your Basis admin, they might have more information.

      Author's profile photo Former Member
      Former Member

      Posting to SFTP using HTTP client class is ok. However still looking for a reasonable way to get files from the same server.

      Author's profile photo J. Graus
      J. Graus


      Would it be possible to install the PI adapter engine stand alone and call the SFTP adapter from ABAP ?

      Author's profile photo Alexei Weißlinde
      Alexei Weißlinde

      In my environment it was possible to install putty on the application server. From there on SM69 and  SXPG_COMMAND_EXECUTE ware my friends.