I'm doing a program that reads all records in physical file using logical file(transaction code, transaction date and transaction amount), checks whether there are 2 or more records with same trans code and trans date, and determine what's the largest amount. I'm supposed to retain the record with the largest amount and delete(delete flag='D') others (with same trans code and trans date).
How will I know what's the record with the largest amount? I mean, if there are 1000 records and I found 7 identical trans code and trans date, if the largest amount is record 7th, how do I delete records 1 to 6 when after reading the file, file pointer goes to the next record,right?
I do apologize if this comes as confusing. This is confusing me as well.