cancel
Showing results for 
Search instead for 
Did you mean: 

Java mapping: Coding to pick the latest values from multiple records.

Former Member
0 Kudos

Hi All,

I have a requirement where I need to pick the latest values from multiple records based on rundate.

The I/P is like this :

<Message>

<ID>1234</ID>

<Name>Raj</Name>

<Name_Date>20150512</Name_Date>\

<SSN>1298</SSN>

<SSN_Date>20150618</SSN_Date>

</Message>

..

<Message>

<ID>1234</ID>

<Name>Ajay</Name>

<Name_Date>20150516</Name_Date>

<SSN>2156</SSN>

<SSN_Date>20150614</SSN_Date>

</Message>


The Output should be:

<Message>

<ID>1234</ID>

<Name>Ajay</Name>

<Name_Date>20150516</Name_Date>\

<SSN>1298</SSN>

<SSN_Date>20150618</SSN_Date>

</Message>


So the logic is that the value of the field should be closest to the RunDate(current date).


Please let me know your feedback on how this requirement can be achieved ?

Accepted Solutions (0)

Answers (2)

Answers (2)

RaghuVamseedhar
Active Contributor
0 Kudos

Arijit,

Please check grouping and duplicate handling example in this blog.

Former Member
0 Kudos

hi Arijit,

You could solve this quite easily with grafical mapping:

Use SortByKey for the root node and use SSN_Date as key.

Map all other fields 1:1.

If your target node has the occurency 1...1 or 0...1, it will only be created once.

best regards,

Heiko

Former Member
0 Kudos

Hi Heiko,

Thanks for your reply.

Please know that there is a date associated with all the fields. In case of duplicate, I have to pick the field value with the most recent "date" field.