Skip to Content
author's profile photo Former Member
Former Member

PI - PDF files as attachments from XML

Hello,

I have a requirement where in I will be receiving a order document as XML along with a PDF attachment, I need to load this order in to R/3 through an IDoc and along with that I need to load the PDF as attachment to the actual Sales order document. My questions is on handling the PDF attachment, I have been reading about options to load the PDF as string in the IDoc and load it in to the Sales Order via IDoc processing module?

is there a better way to achive this?

If this could be done this way through IDoc can you please outline how do I efficiently convert PDF as string and send it in the IDoc from PI.

Thank you.

Let me know if you have any further questions.

Larry.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Jul 21, 2014 at 02:20 AM

    Hi Larry,

    This is usually the code via UDF to convert attachment(s) to string:

    String Content = "";

    String AttachmentID ="";

    GlobalContainer globalContainer = container.getGlobalContainer();

    InputAttachments inputAttachments = globalContainer.getInputAttachments();

    if(inputAttachments.areAttachmentsAvailable())

    {

    Collection<String> CollectionIDs = inputAttachments.getAllContentIds(true);

    Object[] arrayObj = CollectionIDs.toArray();

    int attachmentCount = arrayObj.length;

    for(int i =0;i<attachmentCount;i++)

    {

    AttachmentID =(String) arrayObj<i>;

    Attachment attachments =inputAttachments.getAttachment(AttachmentID);

    Content = Content + attachments.getContent().toString();

    }

    }

    return Content;

    You need to check keep attachments (if it is allowed) in your sender adapter. Another option would be to go Abap proxy as receiver.

    Regards,

    Mark

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Larry,

      Just tried it today and I have a little POC. I have created an inbound proxy with the following message type:

      I have just made it into string but not base64, the reason is that somehow xsd:base64 does not work for me (e.g different values in the backend).

      Here is the code for the provider class:

      Test:

      I have encoded Resume.pdf as it would be in XI when sent as an attachment, the resulting output is attached.

      This output will be the one we will use in testing the proxy.

      Execute the proxy and below is a screenshot of the resulting PDF

      PS: Although your scenario is idoc, make sure that the idoc field is a string. Then you can use the code

      in the proxy class I provided.

      Hope this helps,

      Mark

      Test.png (7.2 kB)
      Test.png (50.6 kB)
      Test.png (24.7 kB)
      Test.png (6.7 kB)
      Test.png (51.2 kB)

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.