on 03-18-2008 1:22 PM
Hi frnds ,
this is Source Structure
<salesorder>
<item>
<ItemDescription>Blazer</itemdescription>
<itemRetailPrice>29.00</itemRetailPrice>
<itemSalesPrice>22.00<itemSalesPrice>
</item>
<item>
<ItemDescription>Blazer</itemdescription>
<itemRetailPrice>29.00</itemRetailPrice>
<itemSalesPrice>22.00<itemSalesPrice>
</item>
<item>
<ItemDescription>Blazer</itemdescription>
<itemRetailPrice>29.00</itemRetailPrice>
<itemSalesPrice>22.00<itemSalesPrice>
</item>
<item>
<ItemDescription>Trouser Fabric</itemdescription>
<itemRetailPrice>29.00</itemRetailPrice>
<itemSalesPrice>22.00<itemSalesPrice>
</item>
</salesorder>
In the Source.xml file there are four item nodes under the 'salesOrder' node. Out of the four 'item' nodes, three have the same 'itemDescription' value of 'Blazer' and the fourth has value of 'Trouser'.
The requirement is to identify nodes with same 'itemDescription' and then aggregate the subsequent 'itemRetailPrice' and 'itemSalePrice' into a single node, so that the output looks like the XML file below.
Now the MYTarget Structure is like this
<salesorder>
<item>
<ItemDescription>Blazer</itemdescription>
<itemRetailPrice>87.00</itemRetailPrice>
<itemSalesPrice>66.00<itemSalesPrice>
</item>
<item>
<ItemDescription>Trouser Fabric</itemdescription>
<itemRetailPrice>29.00</itemRetailPrice>
<itemSalesPrice>22.00<itemSalesPrice>
</item>
</salesorder>
*Plz tell me How to do Message Mapping*
create this UDF:
send a QUEUE of ItemDescription, to do this you must change the context of the field
the header of your UDF must be like this:
Public function getCode (String [] a, ResultList result,Container contanier)
later copy and paste this code. this UDF delete all duplicates from the source document.
/////////////////Code ////////////////////////
Vector vProd = new Vector();
for ( int i =0;i<a.length;i++){
if(!vProv.contains(a<i>)) {
vProv.add(a<i>);
result.addValue((String)vProd.get(i));
}
//////////////end code///////////
your mapping should be:
source field -
>getCode-->SplitByValue-->Target Field
you must use the same function to other fields
temRetailPrice>
<itemSalesPrice>
also see this
/people/stefan.grube/blog/2005/12/29/new-functions-in-the-graphical-mapping-tool-xi-30-sp13
Hope it helps you
Rodrigo
Edited by: Rodrigo Pertierra on Mar 18, 2008 11:06 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Praveen,
Split by Value: insert Context change for an element split by value is some as conter part of Remove
Context.
.
Use splitbyvalue ( ) is the conter part of the removecontexts( )
Inserts a Context change in the Source value Queue.
Context Change in the Queue after each value, after each change to the value, or after an empty TAG..
You Mapped Like this:::
(Source): ITEM--
ITEM (Target)
For this You can use Format by example Or CollapseContexts and SUM...
Collapse Contexts : Copies First values of the all Contexts to one Context Empty Context are replaced by
empty String...
Reward Points If it is Useful..
Thanks,
Satya Kumar...
Edited by: SATYA KUMAR AKKARABOYANA on Mar 18, 2008 3:20 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Praveen,
This link will solve your problem..
/people/stefan.grube/blog/2005/12/29/new-functions-in-the-graphical-mapping-tool-xi-30-sp13
With Regards,
BVS
**********Please reward with points ,if found useful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Praveen
Follow the logic.
Salesorder------>Salesorder
ItemDescription----->SplitByValue[ValueChanged]------->CollapseContext------->Item
ItemDescription----->SplitByValue[ValueChanged]------->CollapseContext------->SplitByValue[Each Value]---->ItemDescription
ItemRetailPrice & ItemDescription---->SplitByValue[ValueChanged] --------->formatByExample----->SUM---->ItemRetailPrice
ItemSalesPrice & ItemDescription---->SplitByValue[ValueChanged] --------->formatByExample----->SUM---->ItemSalesPrice
For the last two logicfor FormatByExample function expects two input, hence
give ItemRetailPrice as the first Input &
give ItemDescription---->SplitByValue(ValueChanged) as the second input
For SUM ,use sum under Statistical function.
raj/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guys,
I tried the logic with out UDF and works fine and there are duplicates when the source xml is
<ns0:Source_SO_MT xmlns:ns0="http://paymetric.com/xi/XIPAYNET_3.0">
<Item>
<ItemDecscrip>Blazer</ItemDecscrip>
<RetailPrice>29.00</RetailPrice>
<Salesprice>22.00</Salesprice>
</Item>
<Item>
<ItemDecscrip>Trouser</ItemDecscrip>
<RetailPrice>29.00</RetailPrice>
<Salesprice>22.00</Salesprice>
</Item>
<Item>
<ItemDecscrip>Blazer</ItemDecscrip>
<RetailPrice>29.00</RetailPrice>
<Salesprice>22.00</Salesprice>
</Item>
</ns0:Source_SO_MT>
The Blazer dosent come under one item. Is there any way we can avoid this using standard functions.
any help would be appreciated
Thanks,
Srini
Hi, Srini:
In this case, you need to use Sort and SortByKey, let me elaborate as follows:
ItemDecscrip --> RemoveContext --> Sort -> SplitValue[ValueChange] -> CollapsContext-->ItemDecscrip
The following logic is for RetailPrice:
FomatByExample:
Input 1: ItemDecscrip --> RemoveContext --->Sort -->SplitValue[ValueChange]
Input 2: SortByKey
SortByKey:
Input 1: ItemDecscrip --> RemoveContext
Input 2: RetailPrice --> RemoveContext
Finally:
FormatByExample --> sum --> RetailPrice
For Salesprice, follow the same logic.
Sorry for the messy explaining.
Liang
Hi Liang,
Thanks for the quick reply. I tried the same logic
ItemDescription>removeContext>sort>SplitByvalue(Value changing)>collapseContext-->ItemDescription
The below sequence was opposite
FomatByExample:
Input 2: ItemDecscrip --> RemoveContext --->Sort -->SplitValue[ValueChange]
Input 1: SortByKey
SortByKey:
Input 1: ItemDecscrip --> RemoveContext
Input 2: RetailPrice --> RemoveContext
Finally:
FormatByExample --> sum --> RetailPrice
when i do this i am getting the following error
Compilation of SO_MM successful Cannot produce target element /ns0:Target_SO_MT/Item[2]/ItemDecscrip.
Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd Cannot produce target element /ns0:Target_SO_MT/Item[2]/ItemDecscrip. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd
when i do disply queue for itemdescription, i am able to see 2 items Blazer, Trouser listed. I am not getting what is wrong ?
any help would be appreciated
Thanks,
Srini
Hi, Srini:
I have successfully executed the scenario in my environment,
There are minor mistakes in my previous post, please follow my current setting:
1. Make sure your all source node, manually change context to Message level, so in mapping logic, there is no more RemoveContext anymore.
2. All Sort or SortByKey Function using default setting:
Lexicographical / Ascending
3. Item Level, you need to map like this:
I am assuming the item is root level element
ItemDescription ->Sort -> SplitByValue[Value Changed] -> CollapsContext -> Item
4. ItemDescription Node:
ItemDescription ->Sort -> SplitByValue[Value Changed] -> CollapsContext -> SplitByValue[Each Value] -> ItemDescription
5. RetailPrice and SalesPrice
5.1: Last Logic
FormatByExample -> Sum -> RetailPrice
5.2 Above FormatByExample take following two Inputs:
Input1: SortByKey
Input2: SplitByValue [Value Changed]
5.3 Above SortByKey take following two Inputs:
Input1: ItemDescription ->
Input2: RetailPrice ->
5.4 SplitByValue in 5.2 take following mapping logic
ItemDescription -> Sort ->
Please let me know if does not work.
Liang
Hi Liang,
Thanks for the reply and the quick reponse, i made all the changes and i am able to see the required output.
The problem is solved and i appreciate your help. I could not give the points as the thread is opened by praveen and he has already set it to answered.
I will surely give the points when i open the thread myself some other time.
Thanks,
Srini
Edited by: srinivas kapu on Mar 18, 2008 1:47 PM
Hi Praveen,
Please use node function remove context for item description.
and use sum function for the retail price and sales price.
let me know, if u find any difficulties.
regard
mahesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.