Hi Thomas,
That's not an easy requirement but could the following approach work for you:
- Sort table RESULT_PACKAGE on VTREF and SETFLAG in ascending order and date field in descending order;
- Loop over RESULT_PACKAGE;
- Read table RESULT_PACKAGE with key VTREF, the different SETFLAG than the once selected and MDRKD
- If found, then delete both records from RESULT_PACKAGE (i.e. with key VTREF and MDRKD);
- After the loop, delete adjacent duplicates comparing VTREF and SETFLAG;
- After that, continue with the logic I suggested on
Best regards,
Sander