Complete guide to sFTP receiver adapter Communication Channel configuration in SAP PI/PO. Each configuration’s parameter functionality explained in detail.
sFTP Adapter Transport Protocol, Message Protocol and Adapter Engine Configuration.
Adapter type ‘sFTP’ has only one Transport Protocol which is ‘SFTP’ itself. Depending on your PI/PO version you can configure the Adapter Engine. Usually, the default Adapter Engine is ‘Central Adapter Engine’ and it will be populated automatically.
Message Protocol – File Content Conversion.
If the target message (file) created by Message Mapping needs to be converted by the Receiver Adapter Communication Channel select the option ‘File Content Conversion‘. Usually, if the receiver file format is anything other than XML, you can use this feature to convert the file to appropriate format such as CSV, Text, etc.
sFTP Receiver Server Destination Configuration.
Defines the TCP/IP of the sFTP server. It can be configured as a host name or IP address.
Default sFTP port is ’22’. This Parameter defines the Port of the sFTP server.
Timeout parameter defines how long the transmitted file remains unacknowledged by the receiver sFTP server. After the defined time (ms), when receiver Communication Channel terminates the connection, set the message to error status and log the error in Message Log.
When you connect to the sFTp server for the first time using any sFTP/FTP clients such as FileZilla, WinSCP, etc., Server Fingerprint will be promoted.
Authentication Methods of sFTP Channel.
There are three Authentication Methods in sFTP adapter:
sFTP Authentication Method ‘Password’.
Password method authenticates the connection with the sFTP server using Username Password combination.
sFTP Authentication Method ‘Private Key’.
Authentication using ‘Private Key‘ method allows us to connect to sFTP server in a more secure way. During design time, system administrators of PI/PO system and sFTP server owners should exchange respective ‘Public Keys’ and install them. Public Key of sFTP host should be installed in PI/PO server and vice versa.
System Administrators (BASIS) maintain the SSH keys in Key Store under ‘Certificates and Keys‘ section of ‘Netweaver Administrator‘
SAP Netweaver Administrator > Configuration > Security > Certificates and Keys.
In older versions of SAP PI or XI key store can be accessed under,
What we configure with Private Key View and Private Key Entry parameters is the SAP PI/PO’s Private Key information. During the system setup (configuration) only Public Keys of the servers are exchanged and installed. At the time of actual connection or handshake with sFTP, Private Key configured in the Communication Channel and Public Key installed in sFTP combination decrypt the data and allow the connection.
Username is the sFTP username.
sFTP Authentication Method ‘Duel Authentication’.
This is simply a combination of ‘Password‘-based authentication and ‘Private Key‘-based authentication.
sFTP File Name and Directory Configuration.
There are several ways to configure the File Name and Directory of receiver files. You can do it by using parameters in the receiver Communication Channel or set the file names dynamically at run-time.
The configuration above defines the receiver file name as ‘test.xml‘, and files will be generated in directory ‘/home/username/in/test/’. Prefix ‘~’ defines the home directory of the user configured in ‘Authentication Method’.
You can also define directory without the prefix ‘~’.
sFTP Processing Parameters, Timestamp to File Name, Message-ID to File Name, Write Mode, etc.
Add Timestamp to filename.
Add the timestamp in format YYYYMMDD_HHMMSS-xxx before the extension of the filename. If the configuration is activated and File Name parameter is set as ‘Test_.XML’, the name of the receiver files will be set as Test_YYYYMMDD_HHMMSS-xxx.XML. ‘xxx’ is a random sequence number generated by Adapter Engine.
Add Message-ID to file name.
Add the PI Message ID to the file name. This is a great way to avoid overwriting files at the receiver by keeping the file name unique.
Write Mode — Direct.
Files are written directly to the specified folder in File Parameter’s Directory.
Write Mode — Temporary Mode.
Files are written at the receiver under temporary names before being converted to the specified format in Communication Channel. Even with timestamp in the filename, there is a possibility of overwriting files when large number of files are generated at the same time (same second). This is the best method to use if there is a chance of receiver picking up the files and processing them while they are being generated by PI/PO. Temporary mode creates each file with a unique name and changes the filename to specified format after file generation is completed.
In Temporary File mode, file names are first set as <timestamp><file name>.tmp. Time stamp here is up to millisecond.
Empty File Handling.
Setting this parameter as ‘Write Empty File‘ will allow you to create empty file in the target directory. Otherwise set it as ‘Ignore‘ so empty files are not created at the receiver directory.
Allow the adapter to save attachments in the PI message and in the target directory.
Run Operating System (OS) Command in Receiver sFTP Adapter.
These two parameters allow us to run OS commands before and after message processing. OS scripts should be defined in Command Line parameter.
Advance Variable Substitution for sFTP File Path and File Name.
Enable Security Check if you want to validate the Directory path for characters such as ‘.’, ‘\’, ‘/‘. If these characters are found after the variable substitution, message is set to error.
Adapter Specific Message Attributes (ASMA) of sFTP Receiver Communication Channel.
Filename and Directory can be copied from the incoming message using ASMA. sFTP Adaper Specific Message Attributes are included under namespace ‘http://sap.com/xi/XI/System’.
In order to use these attributes, you also need to set ASMA in the sender adapter Communication Channel.
Go to message content’s Dynamic Configuration to view these attributes.
Notice the FileName and Directory attributes under “http://sap.com/xi/XI/System/File” namespace. These are automatically set from Sender sFTP Adapter Communication Channel when ASMA is activated. Use them in the Receiver Adapter using Dynamic File Name generation methods.
DynamicConfiguration Section of PI/PO Message Content