on 01-14-2010 11:49 AM
Hi All,
I hve to send a file as an attachment through email and attachment name should be dynamic. I am following blog
http://wiki.sdn.sap.com/wiki/display/stage/DynamicEmailAttachmentnameforReceivedMails .
I am getting the dynamic attachment name but I am not able to get any data in the attachment ie. on opening the attachment there is no data in it. Please guide me in correcting this error.
Regards,
NJ
Hi Nishu,
Hope you are using mail package?
1. Are you sending the content in the Content node of it?
2. Mention here the content description and content type that you have for the attachment.
3. Also the name of the attachment
Regards
Suraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nishu,
Do like this:
1. Create a normal File sender adapter (dont use FCC use it simply as NFS)
2. Read the file and see in MONI how the input paylaod looks like.. It will be as you see it isn a notepad.
3. In the current operation mapping include first a java mapping and then the mapping for generating the mail package structure,
4. The java mapping should have the code:
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
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;
import com.sap.aii.mapping.api.InputHeader;
public class JavaMapping extends AbstractTransformation {
public void transform(TransformationInput arg0, TransformationOutput arg1) throws StreamTransformationException {
getTrace().addInfo("JAVA Mapping Called");
//Input payload is obtained by using arg0.getInputPayload().getInputStream()
String inData = convertStreamToString(arg0.getInputPayload().getInputStream());
String outData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:MT_Generic_Invalid_Record xmlns:ns0=\"http://iata.com/xi/Generic/invalid_record_mail/\"><Content>"+inData+"</Content></ns0:MT_Generic_Invalid_Record>";
try
{
//8. The JAVA mapping output payload is returned using the TransformationOutput class
// arg1.getOutputPayload().getOutputStream()
arg1.getOutputPayload().getOutputStream().write(outData.getBytes("UTF-8"));
}
catch(Exception exception1) { }
}
public String convertStreamToString(InputStream in){
StringBuffer sb = new StringBuffer();
try
{
InputStreamReader isr = new InputStreamReader(in);
Reader reader =
new BufferedReader(isr);
int ch;
while((ch = in.read()) > -1) {
sb.append((char)ch);}
reader.close();
}
catch(Exception exception) { }
return sb.toString();
}
}
The output of this java mapping will be a XML strucure like this:
UPDATED
PS: Cannot put angular brackets the formatting is getting affected. Check your self
5. Map this content with the content of mail package and mention correct content type and description
Regards
Suraj
Hi Suraj,
Thanks for your help, we are using the code given by you but the same is giving syntax error while activating. The error is :
D:\usr\sap\PD1\DVEBMGS00\j2ee\cluster\server0\.\temp\classpath_resolver\Map64750f00010d11dfc0c5001a64d0a1fc\source\com\sap\xi\tf\_MM_FILE_TO_MAIL_.java:140: illegal start of expression import java.io.BufferedReader;
Please guide us on this.
Regards,
NJ
Hi Nishu,
Hope you have added the necessary jar files while compiling the java mapping. If you are in PI7.0 or less use aii_map_api.jar
file and for PI 7.1 you need: com.sap.xpi.ib.mapping.lib.jar
And also hoep you are aware of how to make a java mapping? If not then follow this blog : /people/stefan.grube/blog/2006/10/23/testing-and-debugging-java-mapping-in-developer-studio
Regards
Suraj
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.