Skip to Content

Merging 2 files without bpm

hi all,

i have a scenario where i have to read 2 files merge them and send to traget

I am using additional files option and reading both file .one is coming as main payload and other as attachment .

how can i read this attachment and merge with first file and send it to taget?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Sep 13, 2013 at 08:58 AM

    Hi Sahana,

    I don't think we can read attachments in message mapping. You can write a java mapping to read the attachement and merge it into the main payload.

    Below is the Transform method to merge attachments to mainpayload:

     

    public void transform(TransformationInput in, TransformationOutput out)throws StreamTransformationException

    {

    try

    {

         InputAttachments ia=in.getInputAttachments();

         Collection<String> attachnames=ia.getAllContentIds(false);

         Iterator<String> itr = attachnames.iterator();

         while(itr.hasNext())

         {

          String name=itr.next();

          Attachment atth = ia.getAttachment(name);

          out.getOutputPayload().getOutputStream().write(atth.getContent());

         }

    }

    catch(Exception e)

    {

         throw new StreamTransformationException("Error in java mapping:"+e.getMessage());

    }

    }

    Thanks,

    Anand

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 13, 2013 at 09:34 AM

    Hi Sahana,

    Did you check the following blog & doc that may help you to write udf:

    http://scn.sap.com/docs/DOC-26528

    http://scn.sap.com/people/yugapreetha.t/blog/2009/08/24/read-the-attachments-of-the-input-xi-message-in-the-message-mapping

    or other option is that if you have text files and want to append at the end of the other file

    then you can use append mode in Receiver side while creating a file in CC.

    Regards

    gagan

    Add comment
    10|10000 characters needed characters exceeded