|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
For loop in Mapping node- Migration WMB7 to IIB |
« View previous topic :: View next topic » |
Author |
Message
|
mb8_learner |
Posted: Mon Sep 14, 2015 1:04 am Post subject: For loop in Mapping node- Migration WMB7 to IIB |
|
|
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 |
|
 |
mqjeff |
Posted: Mon Sep 14, 2015 5:27 am Post subject: |
|
|
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 |
|
 |
timber |
Posted: Mon Sep 14, 2015 12:36 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
|
Back to top |
|
 |
martinb |
Posted: Tue Sep 15, 2015 10:52 pm Post subject: |
|
|
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 |
|
 |
|
|
 |
|
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
|
|
|
|