|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Having Problem with lineItems logic |
« View previous topic :: View next topic » |
Author |
Message
|
mohankiran.kopparthi |
Posted: Wed Jun 11, 2014 1:47 pm Post subject: Having Problem with lineItems logic |
|
|
Newbie
Joined: 13 Dec 2011 Posts: 7
|
Hi friends,
I am new to MB and am stuck up in a small scenario. I will get a XML structure having multiple line items and in each line item we have a field ITEM. Now for all unique ITEM Values in line items we have to sum up the quantity and only create a single record. So for example if we have total 10 line items and only 3 item types A,B,C. the output should have only 3 Detail records each representing the item type and each Detail should have the total quantity of that respective ITEM.
Can any one help me on this.... A suggestion would help a lot.
Regards
Mohan |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Jun 12, 2014 4:43 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
I guess your item types are not sorted...
Looking at ESQL you could retrieve per item type using the correct select statement ...
or use a more generic logic that would work both in ESQL, Java, .NET ...
You will need 3 cursors.
One at the first item (new type), one to iterate through the items and one for the target record...
For each value in item type, navigate through all items, move 1st cursor to next item different type, sum for the same type and create target record.
check that 1st cursor moved (no endless loop on last type: if current type is type of 1st cursor item type and item type of second cursor at end of items you're done...), move 2nd cursor to 1st and iterate again...
n items, m types and your mileage is less than m*n ...
Don't forget : no use of indexes! use move next sibling instead...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Jun 12, 2014 5:43 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
kimbert |
Posted: Thu Jun 12, 2014 5:51 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
An elegant solution is probably possible using XSLT in an XMLTransform node. Or even a custom transform in the Mapping node. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
aggarwal.intouch |
Posted: Fri Jun 13, 2014 3:28 am Post subject: |
|
|
 Acolyte
Joined: 30 May 2011 Posts: 56 Location: India
|
For below mentioned test message you can try select statement and then create a XML out of that as per your requirement.
SET ENVIRONMENT.ITEM_A.QUANTITY[] = SELECT A.Quantity from LineItems.Item AS A WHERE A.Quantity = 'A';
<LineItems>
<Item>
<ItemType>A</ItemType>
<Quantity>1</Quantity>
</Item>
<Item>
<ItemType>C</ItemType>
<Quantity>3</Quantity>
</Item>
<Item>
<ItemType>B</ItemType>
<Quantity>2</Quantity>
</Item>
<Item>
<ItemType>A</ItemType>
<Quantity>1</Quantity>
</Item>
<Item>
<ItemType>C</ItemType>
<Quantity>3</Quantity>
</Item>
<Item>
<ItemType>B</ItemType>
<Quantity>2</Quantity>
</Item>
</LineItems> |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|