on 01-14-2015 8:40 AM
Hello All,
We have implemented a file to receiver mail adapter scenario (PI 7.31) , the interface is a pass-through hence no ESR components involved.
Our requirement here is, the source file needs to be sent as mail attachment and attachment name should be dynamic i.e. target file name should be same as that of source file.
I have searched in SCN blogs and found below solutions :
( Not sure if this will work as I see there are many developers commented in the same link that they are facing issues even after implementing this solution)
So , we are just looking if there are any other options apart from the above mentioned, in order to achieve the same. If anybody has achieved this through a different method, kindly let me know .
Thanks in advance.
Hi Kavitha,
We have the same requirement in our project. Could you kindly share what solution was made in your case.
Regards,
Prabhu V
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kavita,
I have a similar requirement. Having a xyz.csv file in AL11 & i want that to be mailed as it is with same name to the recipients. If you have found out a solution for this kindly share the same. I don't want to use ESR, is it possible?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kavita,
I think the main problem is that the attachment treatment changes between PI 7.0 and below to PI 7.1 and above. For example to PI 7.0: Adapter Module PI 7.0 Set Attachment Name - Process Integration - SCN Wiki
If you don't want ESR development, neither custom module development, as far as i know there it not alternative.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kavita
Without using mail package , you will not be able to create the attachment using dynamic name.
You can use message transformation bean to rename the attachment but this will only allows static values.
The simple solution would be use mail package and get the attchment name dynamically. You can do this either by graphical or java mapping.
You have to fill these three fileds in the target mail package
Content Type: text/xml
Content Description: indratest.txt
Content Disposition: attachment;filename="indratest.txt"
Sample Java Mapping Code:
package com.test;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.DynamicConfiguration;
import com.sap.aii.mapping.api.DynamicConfigurationKey;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
public class createAttachment extends AbstractTransformation {
public void transform(TransformationInput arg0, TransformationOutput arg1)
throws StreamTransformationException {
try {
InputStream is = arg0.getInputPayload().getInputStream();
// get the file name from header
DynamicConfiguration conf = arg0.getDynamicConfiguration();
DynamicConfigurationKey dynKey = DynamicConfigurationKey.create(
"http://sap.com/xi/XI/System/File", "FileName");
String filename = conf.get(dynKey);
// creating the attachment
String ContentType = "text/xml";
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String strLine;
StringBuffer data = new StringBuffer();
StringBuffer content = new StringBuffer();
String ls = System.getProperty("line.separator");
String firstline = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns1:Mail xmlns:ns1=\"http://sap.com/xi/XI/Mail/30\">";
data.append(firstline);
String lastline = "</ns1:Mail>";
// Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
content.append(strLine);
content.append(ls);
}
String body = "<Subject>Test Mail using Mail Package in SAP PI</Subject><From>mailpackage@Cognizant.com</From><To>Indrajit.Sarkar2@cognizant.com</To><Content_Type>"
+ ContentType
+ "</Content_Type><Content_Description>"
+ filename
+ "</Content_Description><Content_Disposition>attachment;filename=""
+ filename
+ ""</Content_Disposition><Content>"
+ content.toString() + "</Content>";
data.append(body);
data.append(lastline);
// Close the input stream
br.close();
arg1.getOutputPayload().getOutputStream().write(
data.toString().getBytes("UTF-8"));
} catch (Exception e) {
e.printStackTrace();
}
}// end of transform
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.