cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload/download data file/to from SFTP server in SAP?

sunil_karade
Explorer
0 Kudos

Hello Team,

Client is saving .CSV file in SFTP server on daily basis. we need to fetch it from ABAP custom program and need to do some required data operations.

Could you please help me to fetch that file from SFTP server.? is FM-SXPG_COMMAND_EXECUTE is the right FM to solve this issue? If Yes, then what will be the 'Actual parameters value' needs to pass?. is there any sample ABAP program code?

Note : 1. This is SFTP related issue not FTP.

2. I have created a command using SM69.

3. I am using to connect SFTP server using FM- 'SXPG_COMMAND_EXECUTE'.

Accepted Solutions (0)

Answers (2)

Answers (2)

Tomas_Buryanek
Active Contributor
0 Kudos

Yes it is possible with SFTP (or others, for example LFTP) "command line" command.

You need to explore how to use your selected command and its parameters (it is not ABAP related) and you can then call it with SXPG_COMMAND_EXECUTE in ABAP.


I used LFTP command + SXPG_COMMAND_EXECUTE to upload files to SFTP server in one ABAP class for SFTP and it works OK.

Example bash for upload:

lftp sftp://login:password@host:port -e "cd dir; put filename.csv; ls; bye"
sunil_karade
Explorer
0 Kudos

Hello Thomas,

Thanks you.

I did RND with multiple actual parameters but unable to set SFTP connection.

getting below error.

31 Can't exec external program (8)

44 External program terminated with exit code 1.

can you please provide some screenshot?

Tomas_Buryanek
Active Contributor
0 Kudos

Hi, I am actually uploading bash file above to server (DATASET FOR OUTPUT). And then calling SXPG_COMMAND_EXECUTE with commandname 'ZBASH' (which is just OS command "bash") and in additional_parameters there is bash filename. Which contains above SFTP command.

former_member186746
Active Contributor
0 Kudos

Hi,

You can check the where-used of this function module to see how SAP fills the parameters.

Kind regards, Rob Dielemans

sunil_karade
Explorer
0 Kudos

Hello Rob,

Thank you.

I have done this but unable to connect.