I am using following UDF for my requirement and choosing ASMA in channel, here I am using both filename as well as directory dynamically.
public String setFileName(String input1, String input2, String input3, Container container) throws StreamTransformationException{
String filename = new String("");
String directory = new String("");
DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
DynamicConfiguration conf2 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key2 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","Directory");
Date dNow = new Date( );
SimpleDateFormat ft =
new SimpleDateFormat ("yyyyMMdd_HHmmssSSS");
filename = ft.format(dNow) +"_"+input1+ "_WO_"+ input2 + "_" + input3 + ".XML";
conf1.put(key1,filename);
if(input1=="CR")
{
directory = directory1;
}
else
{
if(input1 =="UP")
{
directory = "directory2";
}
}
conf2.put(key2,directory);
return "";
}
I am getting floowing error
Transmitting the message to endpoint <local> using connection SOAP_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.aii.adapter.file.configuration.InvalidDynamicConfigurationValueException: The Adapter Message Property Directory provided in the message header has an invalid value: ''
Please Help....