How To Add Attachment Using JAVA Mapping
How To Add Attachment Using JAVA Mapping
Ashutosh Upadhyay
more by this author
share
0 share
0 tweet share
0
Follow
1 of 4 2017/10/10, 12:06 PM
How to add attachment using JAVA Mapping (SAP PO) | SAP Blogs https://blogs.sap.com/2015/05/16/how-to-add-attachment-using-java-ma...
Hi,
I was having a requirement to pick a PDF file from a file server, send it
as attachment and PDF file name as field to the target server.
/*
*/
package attach;
/**
*/
import java.io.InputStream;
import java.io.OutputStream;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.Attachment;
import com.sap.aii.mapping.api.DynamicConfigurationKey;
2 of 4 2017/10/10, 12:06 PM
How to add attachment using JAVA Mapping (SAP PO) | SAP Blogs https://blogs.sap.com/2015/05/16/how-to-add-attachment-using-java-ma...
2 Comments
You must be Logged on to comment or reply to a post.
String fresult= ;
3 of 4 2017/10/10, 12:06 PM
How to add attachment using JAVA Mapping (SAP PO) | SAP Blogs https://blogs.sap.com/2015/05/16/how-to-add-attachment-using-java-ma...
fresult = fresult.concat(<FileName>);
fresult = fresult.concat(fileName);
fresult = fresult.concat(</FileName>);
fresult = fresult.concat(</ns0:MT_Payload>);
outputstream.write(fresult.getBytes(UTF-8));
// Write attachment
OutputAttachments outputAttachments =
transformationOutput.getOutputAttachments();
inputstream.read(b);
Attachment newAttachment =
outputAttachments.create(fileName,application/pdf, b);
outputAttachments.setAttachment(newAttachment);
catch (Exception e) {
getTrace().addDebugMessage(e.getMessage());
Output:
Alert Moderator
4 of 4 2017/10/10, 12:06 PM