| Home • Tips • Tutorials • Forums • Certification Q's • Interview Q's • Jobs • Testimonials • Contact Us | ||||||||||||
Tips Categories:
Contribute?What's New?
What's Hot? |
Dynamic File name using ASMA (Adapter Specific Message Attributes) in PI/XIBy 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. Procedure: Design
Part (IR): Prerequisites: All the required
Interface objects have already been created,In the current case the message structures
are:
Message
mapping:
UDF
code:
Code: try { String filename
= ""; String timestamp = ""; DynamicConfiguration conf1 = (DynamicConfiguration)
container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); 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"; conf1.put(key1,filename); 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. Execution: 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.
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 Home • Contribute • About Us • Privacy • Terms Of Use • Disclaimer • Safe • Companies: Advertise on SAPTechnical.COM | Post Job • Contact Us ©2006-2007 SAPTechnical.COM. All rights reserved. All
product names are trademarks of their respective companies. SAPTechnical.COM
is in no way affiliated with SAP AG. Graphic Design by Round the Bend Wizards |
||||||||||||