on 03-27-2007 7:32 AM
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?
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yaa.. have u tried???
Thanks,
Maheshwari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Have u checked? is it working?
Thanks,
Maheshwari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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>
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
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
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>
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
9 | |
9 | |
8 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.