Hi Folks,
I am using SAP PI 7.30 wherein I am creating a Proxy to Mail interface. The data from the proxy needs to be converted into .csv file and to be sent as an attachment in email. Also the file name is to be dynamic which is Companyname_Datestamp.csv. I am facing the issue with the filename.
I have converted the XML content of proxy to flat file content using Message transformer bean module in receiver mail adapter.
I have written the UDF to generate the file name: The UDF is as below:
MappingTrace setAttachmentName_trc;
setAttachmentName_trc = container.getTrace();
String mailHeaderValue = "";
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters().get(
StreamTransformationConstants.DYNAMIC_CONFIGURATION);
// try to create a key
try {
DynamicConfigurationKey keyM1 = DynamicConfigurationKey.create(
"http:/" + "/sap.com/xi/XI/System/Mail", "XHeaderName1");
mailHeaderValue = "attachment; filename=" + fileName;
conf.put(keyM1, mailHeaderValue);
} catch (Exception e) {
setAttachmentName_trc.addWarning("caught exception: " + e
+ " - probably no adapter-specific message attribute.");
e.printStackTrace();
}
return mailHeaderValue;
I am passing a dynamic filename over here as input which changes everyday as date changes. Also I have checked the ASMA properties and Variable Trsnport Binding in receiver mail adapter. The value set for XHeaderName1 is Content-Disposition. But still the name of the file in the attachement is always "Untitled.txt".
Also find the attached Mail receiver adapter screenshot, Dynamic config screenshot of sxmb_moni and UDF code.
Please assist.