In that case you need to select all entries(maybe except for those entries that have datab > sy-datum) and sort them by key and date then delete adjacent duplicates.
To find the key you can use the descriptive classes in ABAP see:
http://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=42965