cancel
Showing results for 
Search instead for 
Did you mean: 

Need help in Mail content setup in message mapping! Please help!

gopalkrishna_baliga
Participant
0 Kudos

Hi Experts

I am sending XML file content as email content (BODY).

My XML file is:

<ns0:MyDN xmlns:ns0="http://www.intel.com/xitrain-06">

<DN_No>1001</DN_No>

<Item>

<Alert_No>KB001</Alert_No>

<Sold_To>2001</Sold_To>

<Descr>Error in DN no</Descr>

</Item>

<Item>

<Alert_No>KB002</Alert_No>

<Sold_To>2002</Sold_To>

<Descr>Error in DN quantity</Descr>

</Item>

</ns0:MyDN>

My email message BODY should be:

DN_No: 1001

*************************

Alert_No: KB001

Sold_To: 2001

Descr: Error in DN no

-


Alert_No: KB002

Sold_To: 2002

Descr: Error in DN quantity

I have a message type which has the same structure as that of XML file.

I have a Mail message type which has fields

From

To

Subject

Content

Now how do I map my XML message type to the "content" field of the Mail message type so that I get the required BODY text as shown above?

Please help!

Any sample code will be very helpful.

Thanks

Gopal

Accepted Solutions (0)

Answers (1)

Answers (1)

MichalKrawczyk
Active Contributor
0 Kudos

hi,

why to one tag (content)

can't you use adapter identifiers to set

some things dynamically (address, subject)?

it much easier then with the "strange mail structure"

approach

it would be much easier as you could set

the content very easily from xml to flat file

that you require (by using the same technique as below)

https://websmp210.sap-ag.de/~sapdownload/011000358700001186732005E/HowToConveModuleJMS.pdf

Regards,

michal

gopalkrishna_baliga
Participant
0 Kudos

Hi Experts,

My input XML is:

<item>

<alert_no>AL01</alert_no>

<sold_to>111</sold_to>

<descr>test1</descr>

</item>

<item>

<alert_no>AL02</alert_no>

<sold_to>222</sold_to>

<descr>test2</descr>

</item>

I have done the mapping like this:

item

alert_no

---> CreateMailBody ---> Content

sold_to

descr

I have created a user defined function in Java named "CreateMailBody". This function has 4 inputs, item, alert_no, sold_to and descr.

public void CreateMailBody(String[] a,String[] b,String[] c,String[] d,ResultList result,Container container){

String mailbody, txt;

mailbody ="";

txt ="";

for (int i = 0; i < a.length; i++){

txt = "Alert No: ";

mailbody = mailbody.concat(txt.concat(b[0]));

result.addValue(mailbody);

result.addContextChange();

}

}

When I test the mapping I always get the content value as

Alert No: AL01

It is not concatenating the alert_no from the second item element.

I am going crazy. Just unable to understand how to solve this.

Please help me! What am I doing wrong?

Thanks

Gopal