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

Creating a zip attachment from java mapping after read an iDoc

Hi, experts.

I have a requirement to send a zip file to a SFTP scenario from an iDoc.

The flow is:

- iDoc in XML with files in segments in base64.

- I have to read those files, extract them from the iDoc and compress all of them in one ZIP.

- Put the XML of the iDoc also in the ZIP file.

- Send the ZIP file to the SFTP.

I am reading the iDoc XML with jdom.

I have tried two approach:

1º) Trying to write it directly to the outputstream using something like

"out.write(decoded, 0, decoded.length);"

but this only sends the xml file, not the binary data to the receiver.

2º) Trying to create an attachment using:

"Attachment newAttachment = outputAttachments.create("","application/zip", data);

But my problem is my execute method to read the XML is only using two parameters:

InputStream in, OutputStream out, and when I use the outputAttachments variable is empty (obviously)

Any idea how can I read the xml and send the zip at the same time?

Thanks and regards,


Add comment
10|10000 characters needed characters exceeded

  • Hi Joaquin,

    I'm not sure if "SAP NetWeaver" is the best primary tag for this. Is this a Java Development question? There's a tag for that. Also, there are a handful of tags related to Process Integration, and I see you chose one of them as a secondary. Would one of those be a better primary tag? It's just that "NetWeaver" tends to be more about architecture, platform, and Basis topics, and this reads like a development question.


2 Answers

  • Posted on Feb 01, 2017 at 06:09 PM

    Hi Joaquin!

    In java mapping you create class that extends AbstractTransformation class. By default you should implement method "transform" that has parameters of type TransformationInput and TransformationOutput.

    Using these parameters you can get access to main payload and attachments.

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Evgeniy,

      I was curious to know if you have ever had success with an adapter that does not support it on the sending side? I still have an open ticket for the AS2 adapter which supposedly supports attachments on the sender side but for some reason I'm not able to generate one inside the message mapping (Try to collect up all errors and attach as an error report in case of a message mapping issue - an optional field that for some business reason must have a value for instance). Strangely enough, I am able to do attachments using the same mechanism for other adapters where attachments are supported. That's why I was wondering if it's tied to the sender adapter and if you had any other experience with that use case.


      Ryan Crosby

  • author's profile photo Former Member
    Former Member
    Posted on Feb 02, 2017 at 09:51 AM

    Hi, everybody.

    Thanks for your answers!

    Ryan is rigth, I cannot create the attachment because the sender is an iDoc.

    The code

    OutputAttachments outputAttachments = out.getOutputAttachments();
    Attachment newAttachment = outputAttachments.create("","application/zip", data);

    Is giving a runtime error because the out variable is TransformationOutput (one of the imput for the transform method) and it comes null.



    Add comment
    10|10000 characters needed characters exceeded