Receiver sFTP Adapter Configuration

Complete guide to sFTP receiver adapter Communication Channel configuration in SAP PI/PO. Each configuration’s parameter functionality explained in detail.

In this article, we will look at these settings in sFTP Adapter,

  1. sFTP Adapter Transport Protocol, Message Protocol, and Adapter Engine Configuration.
  2. sFTP Receiver Server Destination Configuration.
  3. Authentication Methods of sFTP Channel.
  4. sFTP File Name and Directory Configuration.
  5. sFTP Processing Parameters, Timestamp to File Name, Message-ID to File Name, Write Mode, etc.
  6. Run Operating System (OS) Command in Receiver sFTP Adapter.
  7. Advance Variable Substitution for sFTP File Path and File Name.
  8. Adapter Specific Message Attributes (ASMA) of sFTP Receiver Communication Channel.
  9. Communication Channel Adapter Status.
  10. File Archiving technique.

You can also connect SAP directly with FTP file server and create files.


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.

Message protocol configuration of sFTP Adapter in SAP PI/PO
Message Protocols of sFTP Adapter

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 an appropriate format such as CSV, Text, etc.


sFTP Receiver Server Destination Configuration.

sFTP Server, Port and Server Finterprint Configuration in Communication Channel
Server TCP/IP, Port, Timeout and Fingerprint

Server

Defines the TCP/IP of the sFTP server. It can be configured as a host name or IP address.

Port

Default sFTP port is ’22’. This Parameter defines the Port of the sFTP server.

Timeout (ms)

The 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.

Server Fingerprint

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:

Authentication methods on sFTP Communication Channel. Password, Private Key and Duel Authentication
Authentication methods on sFTP Communication Channel
  • Password
  • Private Key
  • Duel Authentication

sFTP Authentication Method ‘Password’.

Password method authenticates the connection with the sFTP server using Username Password combination.

sFTP Authentication using Password
sFTP Authentication using Password

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.

Configuration and installation of Certificates and keys.
Certificates and Keys views of PI/PO can be viewed under NWA.

In older versions of SAP PI or XI key store can be accessed under,

NWA > Configuration Management > Security > Certificates and Keys > Key Storage > Content > Keystore Views.

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 Private Key configuration.
Authentication using Private Key

sFTP Authentication Method ‘Duel Authentication’.

sFTP dual authentication configuration
Dual Authentication in sFTP Adapter

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.

sFTp Adapter filename and directory configuration
File parameters, File name and Directory of sFTP adapter.

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 ‘~’.

You can set the filename and directory dynamically using any of the methods below. Check my previous posts on in-detail examples of each method.


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.

Store Attachments.

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.

Configure Operating System (OS) Commands in Receiver sFTP Adapter
Configure Operating System (OS) Commands in Receiver sFTP Adapter

Advance Variable Substitution for sFTP File Path and File Name.

Parameters defined in ‘Filename’ or ‘Directory’ can be replaced by message payload attributes using this option. For example, replace the file name with a field value from a target message (after Message Mapping). Check out my previous post on how to set the Purchase Order number in the target message to file name using the Variable Substitution method.

Variable Substitution Configuration in Receiver sFTP Adapter
Variable Substitution Configuration

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.

Dynamic Configuration section of PI/PO message holds the filename and directory attributes of the sFTP adapter.
Dynamic Configuration section of PI/PO message

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.


Communication Channel Adapter Status.

If adapter status is ‘Active“, adapter is allowed to exchange messages. If the status is ‘Inactive‘, Communication Channel is blocked from exchanging messages.

sFTP Receiver Adapter Status
Receiver Communication Channel Adapter Status

Archiving of Files.

Archiving configuration allows you to save the files in your PI/PO server. Archive Name parameter defines the location (Directory) of the archive files saved.

Use these substitution parameters to define the Archive location of the PI/PO server.

  • %SEQNUM: A sequence number, starting with 1
  • %RTSEQNUM: A server wide sequence number, starting with 1
  • %START: The start time of the adapter
  • %TIME: The archiving period in milliseconds
  • %MSGID: The XI message ID

if you have any questions on sFTP receiver Adapter configuration or any of the parameters of the Communication Channel, please leave a comment below.

Get the latest tips and tricks on SAP!

8 Comments

Add a Comment

Your email address will not be published. Required fields are marked *

Get the latest tips and tricks on SAP!