Skip to Content

Recently, I happened to discover a nice feature of 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 a 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 obiviously depends on the requirement and individual how these parameters are utilised but below is one of the applcation scenario where I utilised these parameters

In one of my project scenario, i was required to send the files to SFTP application where user which we used to connect to 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 extension of the outbound folder i.e. /outbound in parameter Directory.

SFTPblog_1.jpg

My scenario was that based on the filename (bank types) of the sender i was required to use different users to connect 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 utilise to connect to the SFTP application. If you observe, directory from communication channel perspective would be “/Outbound” for both the bank files while it is the user(RBC/PNC) which varies here.

From interface design approach, I had couple of options before i came to know about the advantco’s variable substitution possibility

1. Ask SFTP application team if they can create user(kind of admin) which has authorisations 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. Thats where I decided to refer documentation of Advantco SFTP adapter to see if there was any possiblity and option to use “username” as 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.

ESR:

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

SFTPblog_2.jpg

Here is the code of UDFs

a.  identifyfileType


String fileName    = "";
String fileType = "";
String bankType = "";
String paymentType = "";
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey file = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File","FileName");
//read Source Filename
fileName = conf.get(file);
bankType = fileName.substring(0,3);
paymentType = fileName.substring(4,7); //determine paymentType
if (bankType.equals("PNC"))
fileType = fileName.substring(0,10);
else if(bankType.equals("RBC"))
{
if (paymentType.equals("ACH"))
{
fileType = fileName.substring(0, 14);
fileName = fileType + "_" + currDate + "_" + currTime + ".txt";
}
else
fileType = fileName.substring(0,17);
}
//set Target Filename
conf.put(file,fileName);
return fileType;






b. setTargetUsername


DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey user = DynamicConfigurationKey.create( "http://advantco.com/xi/XI/SFTP/SFTP","BaseFileName");
conf1.put(user,userName);
return userName;






Integration Directory:

1. Used ASMA for filename in sender adapter

SFTPblog_3.jpg

2. Created Value mappings in ID for maintaing filename-SFTPUSER mapping

3. Created one receiver Advantco SFTP and used variable %username% in parameter User of communication channel

SFTPblog_4.jpg

4. Maintained variable substitution in Advanced tab of the communication channel

SFTPblog_5.jpg

This blog is just a small effort to add a drop to sea of SAP knowledge. Hope you find this useful !!!

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply