cancel
Showing results for 
Search instead for 
Did you mean: 

Merging 2 files without bpm

sahana_ps
Participant
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

anandvithal
Active Participant
0 Kudos

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

Answers (1)

Answers (1)

gagandeep_batra
Active Contributor
0 Kudos

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...

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