cancel
Showing results for 
Search instead for 
Did you mean: 

Attaching a file to a SOAP message

Former Member
0 Kudos

SAP PI (7.11) receives an extended version INVOIC.INVOIC02 IDoc from SAP ECC 6.

The extension segment provides data required to retrieve contents of a PDF file from the outbound SAP ECC system. The retrieval is performed by an RFC which is called at mapping runtime. The RFC returns a string in encoded form representing the contents of the file. The business partner requires the file to be attached to the SOAP message and not passed as a string inside the payload.

sample section of the target payload containing the file contents.

<ns0:Attachment type="FILE">

  <ns0:AttachmentName>FSO302175.pdf</ns0:AttachmentName>

  <ns0:CustomContent>JVBERi0xLjcKNCAwIG9iago8PAovVHlwZSAvUGFnZQovUmVzb3VyY2VzCjw8…….   </ns0:CustomContent>

</ns0:Attachment>

However, the vendor needs this to be included as MIME attachment.

Would checking the "Keep Attachment" option in the receiver soap adapter achieve this?

What would be the best way to do this?

Accepted Solutions (0)

Answers (1)

Answers (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Girish,

You can create attachments via UDF or Java Mapping (adapter module is also viable). Since this is a pdf, you need a java library so that you can create one e.g http://scn.sap.com/people/prakash.singh4/blog/2005/04/05/create-a-pdf-file-using-java

After you have created your PDF  via UDF or Java Mapping(which is most likely to be saved temporarily in AL11), read the file, convert it into output stream and then attach it in your message for ex:

Attachment attachments = output.getOutputAttachments().create(FileName, "application/octet-stream", pdfInByte);

output.getOutputAttachments().setAttachment(attachments);

. Make sure to clean up the file you have saved in AL11.

Regards,

Mark

Former Member
0 Kudos

Thanks for your suggestions Mark.

Since time and effort has been invested in an RFC that is returning the PDF contents as a xstring converting it into binary and saving it as a file before attaching is what I'd like to do. Any suggestions on this are welcome too 

I am working on this and will update the post shortly on my findings.

Cheers,

Girish