ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Having Problem with lineItems logic

Post new topic  Reply to topic
 Having Problem with lineItems logic « View previous topic :: View next topic » 
Author Message
mohankiran.kopparthi
PostPosted: Wed Jun 11, 2014 1:47 pm    Post subject: Having Problem with lineItems logic Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Thu Jun 12, 2014 4:43 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20702
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
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Thu Jun 12, 2014 5:43 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Use the { }.
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Jun 12, 2014 5:51 am    Post subject: Reply with quote

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
View user's profile Send private message
aggarwal.intouch
PostPosted: Fri Jun 13, 2014 3:28 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Having Problem with lineItems logic
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.