Advantco receiver SFTP adapter and Variable Substitution
Recently, I happened to discover a nice feature of the Advantco SFTP adapter which we might have missed checking in any of the other vendor SFTP adapters or even SAP SFTP adapter. The feature which I would like to highlight in this blog is about the extensibility of variable substitution option in Advantco SFTP adapter.
Many times when variable substitution is termed in context of file scenarios in PI, the two parameters which come to our mind are the filename and directories but Advantco SFTP adapter offers something more than that. Below are the parameters for which we can declare as variables in Advantco SFTP adapter
Server Name, User Name, Private Key File, Keystore of Private Key, Alias to Private Key, Known Hosts File, Proxy Host Name, Proxy User Name, Target Directory, File Name Scheme, Directory to Save Attachments
As we can see that there are couple of the parameters which in real time can come handy to decide our integration approach if our PI landscape uses Advantco SFTP adapter. It obviously depends on the requirement and individual how these parameters are utilized but below is one of the application scenario where I utilized these parameters
In one of my project scenario, I was required to send the files to SFTP application where the user which we used to connect to the application was actually the windows user and the directory where files should be placed was “/outbound” which ideally if we observe is equivalent to “c:/users/<myuser>/Documents” of normal windows user and looked something like below, if you observe in below image PGPHOME is the root directory where directory of all the users would be present and pgp is the SFTP user which i need to use in my SFTP communication channel and the directory Outbound seen in yellow is the one where i need to place the file in after connecting to server. Design of the application was such that when I login to application using user the default root directory becomes E:\PGPHOME\<sftpuser> and in channel, I just need to provide an extension of the outbound folder i.e. /outbound in parameter Directory.
My scenario was that based on the filename (bank types) of the sender I was required to use different users to connect the receiver SFTP application so that different bank files are delivered to corresponding outbound directories of different banks. for e.g. if the sender file was for RBC bank then the receiver directory of RBC bank on SFTP application would be E:\PGPHOME\RBC\Outbound while if the sender file was for PNC bank then the receiver directory of PNC bank on the SFTP application would be E:\PGPHOME\PNC\Outbound where in RBC and PNC in the absolute file paths are nothing but the users which I need to utilize to connect to the SFTP application. If you observe, the directory from the communication channel perspective would be “/Outbound” for both the bank files while it is the user(RBC/PNC) which varies here.
From the interface design approach, I had a couple of options before I came to know about the Advantco variable substitution possibility.
1. Ask SFTP application team if they can create user(kind of admin) which has authorizations to directories of all the bank users and use variable substitution for directory in communication channel and creating directory to be used by means of udf.
2. Creating one communication channel one receiver per bank file which I receive from sender and filter the receiver based on the filename in the which is picked by PI from sender.
From re-usability perspective option2 above was complete NO because with each new bank there would be 6 new objects need to be created in PI so i was not interested to follow that but on my discussion with the SFTP application team for option1 i was left disappointed as they had limitations from security perspective in creating any super user which can access directories for all the other users. That's where I decided to refer to the documentation of the Advantco SFTP adapter to see if there was any possibility and option to use “username” as a variable was something which caught my attention and i was happy since my efforts of going through documentation proved to be fruitful 🙂 and I decided to use this approach of using same channel to connect SFTP application and below is my brief interface design.
1. Created UDF which would read the sender file name and used value mapping for identifying SFTPUSER. I assigned SFTPUSER to one of BASEFILENAME header attributes of SFTP adapter.
Here is the code of UDFs
1. Used ASMA for filename in sender adapter
2. Created Value mappings in ID for maintaining filename-SFTPUSER mapping
3. Created one receiver Advantco SFTP and used variable %username% in parameter User of communication channel
4. Maintained variable substitution in Advanced tab of the communication channel