cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping parts of a simple message array

Former Member
0 Kudos

Hi,

Suppose i have the flowing MT:

Root: 1..1

Item: 1..Unbound

Row: 1..1

Which contain the following message:

<Root>

<Item>

<Row>My flat file header...</Row>

</Item>

<Item>

<Row>My flatfeet row 1...</Row>

</Item>

<Item>

<Row>My flatfeet row 2...</Row>

</Item>

...

<Item>

<Row>My flatfile trailer...</Row>

</Item>

</Root>

And i want to map it to the following MT:

Root: 1..1

Header: 1..1

Row: 1..1

Body: 1..Unbound

Row: 1..1

Trailer: 1..1

Row: 1..1

So the result will look as folows:

<Root>

<Header>

<Row>My flatfile header...</Row>

</Header>

<Body>

<Row>My flatfile row 1...</Row>

</Body>

<Body>

<Row>My flatfile row 2...</Row>

</Body>

...

<Trailer>

<Row>My flatfile trailer...</Row>

</Trailer>

</Root>

What is the most simple way to do this?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Abel,

Check this.... whether u hv done the same?

Row>UDF>SplitByValue(Each Value)--->Header

Row>UDF>Row

UDF :

result.addValue(row[0]);

Row>UDF>RemoveCOntext--->Body

ROw>RemoveContext>UDF>SplitByValue(Each Value)>Row

UDF :

for (i=1;i<row.length-1;i++)

{

result.addValue(row(i));

}

Row>UDF>SplitByValue(Each Value)--->Trailer

Row>UDF>Row

UDF :

result.addValue(row[row.length()-1]);

This works fine.

Thanks,

Maheshwari.

Former Member
0 Kudos

Hi Maheshwari,

According to this design it's finally working!

Thanks a lot everyone,

Yigal.

Answers (6)

Answers (6)

Former Member
0 Kudos

Yaa.. have u tried???

Thanks,

Maheshwari.

Former Member
0 Kudos

Hi,

Have u checked? is it working?

Thanks,

Maheshwari

Former Member
0 Kudos

No.

Now i get a mapping error.

Did you realy mean: <b>Row->UDF->RemoveContext--->Body</b> ??

Former Member
0 Kudos

Hi Yigal,

UDF given by Chilla is working fine.

just do one change.

Map body with 2nd UDF

<b>Row-UDF-RemoveContext---Body</b>

UDF..given by Chilla

for (i=1;i<row.<b>length-1</b>;i++)

{

result.addValue(row(i));

}

Thanks,

Maheshwari.

Reward points if helpful

Former Member
0 Kudos

HI,

It is better to write a UDF.

see the below details

creat UDF with the option of queue and input are Row

row - removecontext -- UDF--splitbyvalue -- Header: 1..1.-Row: 1..1

here UDF

result.addValue(row(0));

row - removecontext -- UDF--splitbyvalue -- Body: 1..Unbound.-Row: 1..1

here UDF

for (i=1;i<row.length;i++){

result.addValue(row(i));

}

and map the Body with empty Constant

row - removecontext -- UDF--splitbyvalue --Trailer: 1..1-Row: 1..1

here UDF

result.addValue(row(row.length()-1));

Regards

Chilla

Former Member
0 Kudos

Hi Chila,

I'm almost there, its just that my Body rows gets only the first row.

Although when i click "Display Queue" before the Body\row i see all the rows between the Header and Trailer, my out massage looks like this:

<Root>

<Header>

<Row>My flatfile header...</Row>

</Header>

<Body>

<Row>My flatfile row 1...</Row>

</Body>

<Trailer>

<Row>My flatfile trailer...</Row>

</Trailer>

</Root>

prabhu_s2
Active Contributor
0 Kudos

set the context of item to row

Former Member
0 Kudos

Can you clarify because i don't really understand

Former Member
0 Kudos

HI,

Sure the above function will work.

Ca you plz check, whether you have placed the removecontext left side and SplitByValue function right side to UDF --for the Body-1.1 - Row-0..un as mentioned above.

Regards

Chilla

Former Member
0 Kudos

Hi Chila,

I did.

But the case is not Body:1..1 - Row:1..Unbound, but Body:1..Unbound - Row:1..1.

I assume here you got it wrong.

Can you check this?

Thanks,

Yigal.

Former Member
0 Kudos

Hi,

No it will work fine , please let me know the exactly waht you have done , donot change any context if you use the removecontext you need not to change the context.

map the item to body. sure it will work.

on way is check first both sides eliminate the splitby value and verify.

Regards

Chilla

Former Member
0 Kudos

Hi Chila,

By doing the last thing you said "...map the item to body" i get a mapping error.

<i>Cannot produce target element <b>/p2:ExchangeFile_MT/Record/Body[2]/Row</b>. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd</i>

What i' did exactly is:

Created UDF with the option of queue and input are Row

Maped <b>Empty Constant to Heder</b>

Mapped Item/Row to Header/Row like this:

<b>Row - removecontext -- UDF-- Header: 1..1.-Row: 1..1</b> here UDF

result.addValue(row(0));

Maped <b>Item to Body</b>

Mapped Item/Row to Body/Row like this:

<b>row - removecontext -- UDF -- Body: 1..Unbound.-Row: 1..1</b> here UDF

for (int i=1;i<row.length-1;i++){

result.addValue(row(i));

}

Maped <b>Empty Constant to Trailer</b>

Mapped Item/Row to Trailer/Row like this:

row - removecontext -- UDF--Trailer: 1..1-Row: 1..1 here UDF

result.addValue(row(row.length-1));

If this is not what you ment please let me know.

Regards,

Yigal

Former Member
0 Kudos

Hi,

Try below..

Maped Empty Constant to Heder ... not require. Empty constant to be mapped when it is 1..unbound or 0..unbound -- So -Leave it -do not map

1)Row - removecontext -- UDF-- Row: 1..1 under Header: 1..1.-

here UDF

result.addValue(row(0));

2)Maped Item to Body

row - removecontext -- UDF --Splitbyvalue -- Row: 1..1 under - Body: 1..Unbound.

here UDF

for (int i=1;i<row.length-1;i++){

result.addValue(row(i));

}

3)Maped Empty Constant to Trailer -- not require -- leave it --do not map any thing

row - removecontext -- UDF--Trailer: 1..1-Row: 1..1 here UDF

result.addValue(row(row.length()-1));

Regards

Chilla

<i>rewrd points if it is helpful..</i>

prabhu_s2
Active Contributor
0 Kudos

does the first and the last message in the source always carry the header and trailer? if yes then u can make use of udf....make use of context changes

prabhu_s2
Active Contributor
0 Kudos

u might need to use a udf for this f/n.....as the header,item and trailer all are in the same source message in a seq u might need a udf or ember some logic to get it done without using a udf,.

Message was edited by:

Prabhu S