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
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************************