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)

To report this post you need to login first.


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

  1. Ranjit Deshmukh
    Hi Shabz,
    In points to remember here is one more that you can add:
    As you are likely to get an exception while using the test tab, why dont you implement UDF with some try-catch block?
    //here goes your DynConf code
    catch(Exception e)
    //write here what you want to do

    in this way you can avoid the exception.


    (It seems you have fallen in love with File adapter is it true?? 😉 )

    1. Shabarish Vijayakumar Post author
      (It seems you have fallen in love with File adapter is it true?? 😉 )
      well she was my first love since I been in the XI space … amazes me …. always have she and always will she


      i will update the post with your comments soon.. thanks !!!

  2. Divya Vidyanandan Prabhu
    your blog gives a very good insight into accessing attributes dynamically. But you also have mentioned variable substitution.Can you please throw more light on this? or provide links for the same??

    Thanks and Regards,

  3. Juan Manuel
    Thanx a lot Shabarish, it’s a really useful blog, and I think that is clearly shown that Dyn.Conf is better than Variable Substitution.


  4. Juan Manuel
    Hi Shabarish,

    I faced a situation where I have to use Var. Subs instead Dynamic Conf.
    An Idoc comes to PI, and then I have to do a 1:N mapping (with Enhanced Interf. Determination) to create many files (each one with its own name), as segments come from the Idoc.

    So, in this case, I tried to use the Dyn. Conf. but the AE is the one that splits the SOAP Full Message, so the Dyn. Conf (FileName) is only one for all the messages, so I had to use Var. Substitution in this case.

    Hope this could help someone,

    P.D. Very nice blog



  5. Saurabh Sharma
    Hi Shabrish,

    This is really a very important information as very often we face the problem in which certain part of input file name is required on the output file name. Moreover the manner in which u have presented this blog is really very nice .We are getting information with fun.




Leave a Reply