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 » For loop in Mapping node- Migration WMB7 to IIB

Post new topic  Reply to topic
 For loop in Mapping node- Migration WMB7 to IIB « View previous topic :: View next topic » 
Author Message
mb8_learner
PostPosted: Mon Sep 14, 2015 1:04 am    Post subject: For loop in Mapping node- Migration WMB7 to IIB Reply with quote

Novice

Joined: 28 May 2013
Posts: 22

I have to check the Name value for 'def', if it matches need to map the Address value to the target field.
In the below case, we have two Name field values as 'def', then the last occurence Address value needs to override the previous value.
I want the output value as 'Mysore'.

In WMB7, we have used mapping node. in that we have for loop to iterate the Data array.Inside for we have IF to check the name value for 'def' and we ll map the address value to target field.

But while migrating the messagemap to map, for is converted to foreach and in IIB its generating multiple Address fields(since we have two name vale as 'def', its generating two address fields with mumbai and mysore value)
I need one address field in target with the last occurence value. Please advice.

WMB7 code:

For - $source/Test/Data
IF - $source/Data/Name = 'def'
Map Address to Target field.

Test Data:

<Test>
<Data>
<Name>abc</Name>
<Address>Chennai</Address>
</Data>
<Data>
<Name>def</Name>
<Address>Mumbai</Address>
</Data>
<Data>
<Name>def</Name>
<Address>Mysore</Address>
</Data>
</Test>
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Sep 14, 2015 5:27 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

It's not clear that the behavior you had in v7 was actually correct function.

I'm also not sure that you can accomplish this using plain mapping functions - I suspect you will need to use a custom function - java or ESQL or etc.

And you'll have to do that outside of a foreach loop, because otherwise it will be called with each element without being able to tell whether you're at the last element or not.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
timber
PostPosted: Mon Sep 14, 2015 12:36 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1292

Disclaimer : I am not an XPath expert, not by a long shot.
With that out of the way...

I think you may be able to do this fairly simply using a Custom XPath transform.
https://www-01.ibm.com/support/knowledgecenter/SSMKHH_10.0.0/com.ibm.gdm.doc/cm28646_.htm

It is reasonably easy to select the last element in a sequence of matching elements...if you get the parentheses in the right place:
http://stackoverflow.com/questions/1459132/xslt-getting-last-element
Back to top
View user's profile Send private message
martinb
PostPosted: Tue Sep 15, 2015 10:52 pm    Post subject: Reply with quote

Master

Joined: 09 Nov 2006
Posts: 210
Location: UK

Indeed as "mqjeff" says as you've described and shown the v7 code, it sounds like the outcome there was not correct?
The two entries with 'def' should get mapped.

Anyway the new Graphical Data Mapper "For each" transform provides a "filter" expression property. This expression is applied to each entry in the input data and only if it's result is true will the nested mapping be entered and executed.

It also provides two variables that provide the input index, and count of number of matched mappings. So you could add conditions based on these.

Refer to

For each
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » For loop in Mapping node- Migration WMB7 to IIB
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.