Dynamic File name using ASMA (Adapter Specific Message Attributes) in PI/XI

By Ramakrishna Kopparaju, Yash Technologies

There has been an added feature from SP14 onwards to handle the Message Attributes dynamically using AdapterSpecificMessageAttibutes (e.g. Filename). This feature has been demonstrated with one of the example below using File adapter.  

Business case:

There was a requirement in one of our interfaces to get the  same file name that sender places in his FTP and get the same name as file name with the added time stamp separated by the “_ “(underscore) symbol on the target side.

Ex: Source side file name (DynamicPO.txt has to be converted to DynamicPO_<timestamp>.xml).  

Technical challenge:

Time stamp can be added at the end of the file name by specifying the Add Timestamp parameter .But our requirement is to put underscore between filename and time stamp which is not possible in the former case. To achieve this we can make use of ASMA and modify the file name according to our requirement.  


Design Part (IR):


All the required Interface objects have already been created,In the current case the message structures are:  

Source Structure


Target Structure

Message mapping:  

  • Create an UDF and include the piece of code that captures the Filename and Timestamp from source side via ASMA. 

  • Modify them according to our requirement by adding the <Timestamp> at the end of <filename>.

  • Map the UDF to any of the top level node so that the modified filename will be available for the target communication channel.

UDF code: 



try {

String filename    = "";

String timestamp = "";

DynamicConfiguration conf1 = (DynamicConfiguration) container



DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");

DynamicConfigurationKey key2 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","SourceFileTimestamp");

filename = conf1.get(key1);

timestamp = conf1.get(key2);

filename = filename.replaceAll( ".txt" ,"_" );

filename = filename+timestamp+".xml";


return filename;


catch(Exception e)


     String exception = e.toString();

      return exception;


Configuration Part (ID):

à In the sender side communication channel, Mention *.txt as file name to pick all the txt files that will be placed in the source directory.


à Click on Advanced tab and check the Option “SetAdapterSpecificMessageAttributes” in addition to that check the attribute that are required to be captured during run time. In our case File Name and Source File Time Stamp are required to be checked as shown in the below picture.


--> In the receiver communication channel Mention ‘ * ‘as File Name Scheme.

à Click on Advanced tab and check the Option “SetAdapterSpecificMessageAttributes” in addition to that check the attribute “File Name” which will carry the modified value in the UDF in mapping as shown below.

à Create the Remaining IR objects as usual, save and activate them.  


Now it’s the time to test the interface .Place the “.txt” file in the source directory and execute scenario. After successful execution you will see the “.xml” file (as my scenario is FCC to xml) created by the name that in way it has been modified in the UDF using Dynamic Configuration.

Sender system

Receiver System


Runtime Workbench:  

The checking of options ASMA in communication channel allows sender file attributes to be available in RWB as shown in the figure to see them Go to  sxmb_moniàclick on the messageà Inbound messageàSOAP HeaderàDynamic Configuration.  

File name and timestamp in SXMB_MONI (Before Modification ) :

Go to sxmb_moniàclick on the messageà Call Adapter àSOAP HeaderàDynamic Configuration.

File name in SXMB_MONI (After modification Modification using Dynamic Configuration):

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image