Currently Being Moderated

Variable substitution or the Dynamic configuration??


I sensed a lot of distress among the 'Jedis' recently in the forums on the above matter. There is a great disturbance in the 'Force' and in this blog I will try to lay down my thoughts on that matter and maybe bring a bit of 'balance' in my very own way!!!


So here is a little history to start with;


Once upon a time, long long back ago when XI (XI 2.0) was born and was in its adolescence (XI 3.0), most of the 'Jedis' found that there was a need to dynamically name files. The 'Jedi Masters' were in a desperate need. Most of them found work arounds, twisted ones I say but that worked. This went on for sometime. The issue was raised multiple times in the forum of the 'Senate' and one bright sunny day on the distant planet 'Nebula' the 'Senate' declared that new powers were to be bestowed upon XI, it was called Variable Substitution. No more workarounds was now needed.


So now this happened long back ago. But soon as times changed, the 'Senate' decided to confer more powers to XI that was supposed to bring balance to the 'force' . The year was XI 3.0 SP14 (in human terms it was sometime towards the end of 2005 AD).


It was now more than about dynamic file names. It was now about DYNAMIC EVERYTHING. It was called Dynamic Configuration clubbed with ASMA (Adapter Specific Message Atrributes).


Today XI has grown (its still growing and getting more powerful). From XI 2.0, it took different shapes and names (XI 3.0, PI 7.0 and now PI 7.1). But still lot of Jedis mostly the upcoming ones find their loyalty with variable substitution. In this blog I would like to show them the brighter side of the 'force'. Show them more about the new times and why they should move on and accept the Dynamic Configuration.


First of all lets talk about existing blogs/materials around this topic;


This Blog written by The 'Jedi Master' Michal Krawczyk show cases an ideal scenario where in a File to File scenario, you want to have the same name as in the source file to be populated for the target file. Base this as your first reference along with the SAP Help Link Accessing Adapter-Specific Attributes.


For Dynamic configuration to work, the important point to note is the enabling of ASMA properties in the required adapter.



The Problem of using Variable Substitution:


So what if I am loyal to Variable Substitution? If you have asked this question yourself and have not been able to find the right answers, then read on.


Variable substitution requires you to have the filename as part of your target payload. As long as you have no issues with having the file name as part of your payload when you transfer it to your target system, variable substitution can be used. I am with you on that


But imagine that whatever you want as the file name should not be part of the target payload when it is finally transmitted to the target system. The you will have to now use some workarounds to remove the particular field or value from the XML. Most common way of doing this is in a FCC using the  Parameter Name <Node>.fixedLengthTooShortHandling and using the value Cut.


The hurdle with that is it leaves an empty line for that particluar record after the FCC is done. Also what if you wanted to actually pass out an XML File itself Now you cant use FCC , isnt it?



Code the Dynamic Configuration:


I will use some scenarios to walk you through this one.


1. File A to File B scenario - Need the same source File name as Target File Name


Refer Mike's blog I mentioned earlier on



2. File A to File A scenario - In this case same file needs to be transferred via XI


No coding required. No mapping required. Just enable ASMA in both source and target communication channel



3. Source is IDoc/JDBC/RFC/HTTP i.e anything. Need file name based on values from the source XML fields.


Q. I need my file name as <PONumber>_<CurrentDateinDDMMYYYYFormat>.xml. PONumber value has to be taken from the source field PONumber. Also I need the date in a particular format i.e DDMMYYYY


Ans.Create a UDF with two inputs.

a - Field PONumber

b - currentDate function with formatting as DDMMYYYY



The code will be


DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create(“”,“FileName”);
String MyFileName = a + "_" + b +".xml";
conf.put(key, myFileName); 


Map the output of the UDF to the Root node of the target message.



Points to Remember when using Dynamic Configuration/ASMA:


a. During independent testing in Message mapping, the UDF is prone to throw errors esp. when you have conf.get( ) in the code. Note that the code populates the values during runtime only.


b. End to End testing - That will show you the right results.


c. In case you still want to independently test the mapping apart from the dymanic conf code, just remove the mapping and test. Else if the UDF is mapped to any field, then disable the field and continue with the testing.


d. You can also add a try catch block around your code to catch exception to be passed. This will avoid the issues as mentoned in point 'a' above.




{// the dyan. conf. code here } 
catch(Exception e) 
{//In case advance UDF 
// else in case of simple UDF
String exception = e.toString();
return exception;


e. ASMA checkbox and respective parameter should be enabled in the required Adapter.



Additional Info - Dynamic Configuration in Java and ABAP Mapping



My Conclusion: If your SP level supports the usage of ASMA/Dynamic Configuration avoid Variable Substitution. I am for going ahead with the Dynamic Configuration since it provides you much flexibility in terms of coding your requirement. But still, its a personal choice. If you cant let go, all I can say is "may the force be with you"



Note:Dynamic configuration along with ASMA is not only useful in dynamically reading/creating FileNames but it can be used on all attributes of a particular adapter type. For example in case of File Reciever adapter, you can populate FileName, File Type, FileType, File Encoding and Temporary Name Scheme for Target File Name. You can find the details per adapter (not only FILE) in SAP Help documentation for the adapter type in the section Adapter-Specific Message Attributes




XI/PI Consultants as The Jedis

SAP themselves as The Senate &

The SAP XI/PI Integration Domain as The Force



(Being a big fan of the Star Wars series, thought I will express my thanks & gratitude to the Makers of a magnificent series of cinema via this post in my own little way)



Filter Blog

By author:
By date:
By tag: