cancel
Showing results for 
Search instead for 
Did you mean: 

Split Message

Former Member
0 Kudos

Hi All,

I encountered one question in the mapping. The following is my source message:

<MsgIn>

<SID>1</SID>

<SID>2</SID>

<Goods>

<Name>G1</Name>

<Price>10</Price>

</Goods>

<Goods>

<Name>G2</Name>

<Price>20</Price>

</Goods>

</MsgIn>

I wanted to get the following result by message mapping:

<MsgOut>

<Out>

<SID>1</SID>

<Goods>

<Name>G1</Name>

<Price>10</Price>

</Goods>

<Goods>

<Name>G2</Name>

<Price>20</Price>

</Goods>

</Out>

<Out>

<SID>2</SID>

<Goods>

<Name>G1</Name>

<Price>10</Price>

</Goods>

<Goods>

<Name>G2</Name>

<Price>20</Price>

</Goods>

</Out>

</MsgOut>

Did anyone encounter the same question?

Accepted Solutions (1)

Accepted Solutions (1)

former_member214364
Active Contributor
0 Kudos

Hi Chris,

I guess your mapping needs UDFs.i tried without UDFs but could not find any solution,so finallay i came up with 2 UDFs.

1. when you are mapping <b>Goods</b> in Source with <b>Goods</b> in target use the following <b>Context</b> UDF code

//write your code here

for(int k = 0;k < b.length;k++)

{

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

result.addValue("");

if(k != (b.length-1))

result.addValue(ResultList.CC);

}

This UDF takes 2 inputs <b>a</b> and <b>b</b>.

<b>a</b>: Goods node from Source

<b>b</b>: SID element from Source

2. when you are mapping <b>Name</b> field in Source with <b>Name</b> field in Target use the following - <b>Context</b> UDF

//write your code here

for(int k = 0;k<b.length;k++)

{

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

result.addValue(a[j]);

}

This UDF takes 2 inputs <b>a</b> and <b>b</b>.

<b>a</b>: Name node from Source,but change context to <b>MsdIn</b>

<b>b</b>: SID element from Source

<b>Note:</b> The output of this UDF send to <b>SplitByValue</b>[Each Value] and output of this send to <b>Name</b> field in target

3. Use same UDF and logic as <b>Name</b> field for <b>Price</b> field mapping

please let me know if you have any issues regarding this.

Thanks,

Jag

former_member614185
Contributor
0 Kudos

Hi jag,

Thats great,

I just tried with your UDF, its working fine. i think it would be the good solution for Chris.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Jag,

Your UDF work fine. That's great. Thanks.

Former Member
0 Kudos

SID / Goods- > Out ( target)> this specifies the no of times SID/Goods occur in source those many times u want Out node to occur in the target.. give a thought for context as well

map SID -> SplitByValue--> SID ( this is to put each occurrence of SID into different parent Out

Map Goods as like SID

Former Member
0 Kudos

Hi,

your target message occurance should be unbounded.

mapping your source field (SID) to target message.

Thanks

Anu SInghal

<b>Reward point if useful to u in nyway!!</b>

Former Member
0 Kudos

Hi,

use the Useoneasmany or copyvalue function tocopy the <goods> node and the fields several times as in the source u might have only one set of <goods> node for all the SID

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

Map the SID to Out.and

Then Map

SID -


SID

Name -


Name

Price -


Price

Regards

San

there is a Way.