Human Capital Management Blog Posts by Members
Gain valuable knowledge and tips on SAP SuccessFactors HCM suite and human capital management market from member blog posts. Share your insights with a post of your own.
cancel
Showing results for 
Search instead for 
Did you mean: 
biswajit_a_sahoo
Explorer
106,140
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.

Usage:

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 .

Example:

OPEN DATASET Filename FOR access IN mode [position]
[os_addition]
[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************************
18 Comments
Sandra_Rossi
Active Contributor
Here, you are talking only about HTTP. I don't see where SFTP is. Can you explain?
biswajit_a_sahoo
Explorer
0 Kudos
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 ).

Thanks.
ec1
Active Participant
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.

 

Regards,

Stev
0 Kudos
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.
Sourav1
Participant
0 Kudos
What should be the content type here?application/x-zip-compressed?
biswajit_a_sahoo
Explorer
0 Kudos
Hey Surav,

Content type indicates , which type of content you are going to store into SFTP depending on request method .

If request method is put , then convert your complete data into xstring format and pass on that parameter .

If request method is get , then you are going to receive the data in a xstring format and convert it as per your use .

Thanks.
former_member700361
Discoverer
0 Kudos
Hi Biswajit,

Great blog post!

I tried to get a CSV file from SuccessFactors SFTP using your instructions, but without success...

Could you please specify your example a little bit more ?
Maybe with coding and pictures?

That would be really great!

Regards,
Marco
BalasubramanianAP
Active Contributor
0 Kudos
Short and sweet content...
goutham2903
Explorer
0 Kudos

Hi Biswajit,

 

Your content is very high level. I am not sure its going to help many as most will not be able to understand. I wish you could have put more details with an example and this would have been a great blog.

 

Appreciate your work!!

 

Thank you,

Goutham

Archie-Hammer
Explorer
0 Kudos
Is there any additional information you can provide on accessing the SFTPs rest APIs? this could prove useful in the future when accessing SuccessFactors SFTP services.
ec1
Active Participant
0 Kudos
Have a look at sap note 2498454. SAP provides a sample program to do this.

 

Stev
ec1
Active Participant
0 Kudos
SF uses Globalscape and here is the only REST API documentation I can find

https://kb.globalscape.com/Knowledgebase/11297/EFT-HTTP-API-using-Curl

Stev
0 Kudos
Can you pl explain with screen shots
Daniele_Sgi
Participant
0 Kudos
It doesn't work for me too ... yet I followed all the steps and details in note 2007916 and your post, and SM59 connection is tested correctly.

Receiving HTTP ERROR when sending file: FILE_TEST.TXT, Code: 501, Reason: Not Implemented

 

Can you pl explain with screen shots ?
ADO
Explorer
Hello,
​I have a question to the Blog "Hows To Transfer Files Into SFTP using ABAP Program"

​What have I to maintain in SM59?
​Normally SFTP has an URL like sftp://....... and Port 22.

​But I think this is not the URL we have to put in SM59 RFC-Destination. If we try to do this we get an Error like
"​Connect to sftp://myopenfactory.net:22 failed: NIEHOST_UNKNOWN(-2)"

Can you someone help me​?

​Thanks
akgfgn
Explorer
0 Kudos
Hi Arnfried, how did you resolved this issue?
akgfgn
Explorer
0 Kudos
Hi Daniel, are you able to transfer the data via HTTP connection approach using ABAP to SFTP server ? I have followed all the steps in Note 2007916 and I have tested SM59 connection successfully.

I am trying the same, but I am getting return code 200 and reason as OK. When the file successfully created at the target the expectation is to get a return code 201 and reason created.

Regards, Anil.
Frank_Haschick
Explorer
0 Kudos
This is not an SFTP-Implementation as this uses HTTP. You make more or less a REST call, not an SFTP-call. I'm not sure if there is an "ABAP only" way to do an SFTP transfer in an onPremise-system.
Labels in this area