cancel
Showing results for 
Search instead for 
Did you mean: 

Concat of 1st and 2nd occurrence of same field using graphical mapping

Former Member
0 Kudos

Hi All,

I have a scenario where I need to populate the first line in the text with just the date and the first sequence' text value. the second line onwards, we need to concatenate the remaining sequence' text values using the input received without date.

My input XML is

<memoList>

<memo>

<seq/>

<date>20090202</memoDate>

<text>1</text>

</memo>

<memo>

<seq/>

<date>20090302</memoDate>

<text>2</text>

</memo>

<memo>

<seq/>

<date>20090402</memoDate>

<text>3</text>

</memo>

</memoList>

My Output XML should be

<HEADER >

<TEXT>200902021</TEXT>

</HEADER>

<HEADER >

<TEXT>23</TEXT>

</HEADER>

How can I acheive this using Graphical mapping?

Thanks,

Sheela R

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Go for UDF:

Execution type as : All values of a Context.

There will be 2 Inputs : var1 type String

var2 type String

UDF:

int a = var1.length;

String b = "";

result.addValue(var1[0]+var2[0]);

for(int i=1;i<a;i++)

{

b=b+var2 i; ("i" is under square brackets)

}

result.addValue(b);

Ur mapping will be:

var1->RemoveContext

-


UDF--


SplitByValue(Each Value)-----Target

var2->RemoveContext

Thanks

Amit

Edited by: AmitSri on Sep 3, 2010 1:40 PM

Former Member
0 Kudos

Hi Sheela,

Try this mapping:

On the target staructure, rightclick on HEADER Node and duplicate it for one time.

For the first HEADER Node Text element:

date--->

concat ---> TEXT

text --->

For the second HEADER node Text element:

You have to use UDF here to get the concatenated values of all text elements.

In UDF, read all the values of the Text (except the first one), concatenate & pass the single value to the target TEXT field.

-Supriya.