From: James Moore To: All
I have a program where I need to look at the last payment made in our payment file. I have been looking for ways to do this without CHAINing to the file and then using SETGT and READP. I couldn't find any way to do this with OPNQRYF or join logicals. Using select criteria won't work because the last payment made may span across years. For example, in January 1993, it's likely that the last payment date is December 1992.
Am I missing any possibilities here? I would really like to improve performance as all payments ever made are kept in this file. Any ideas would be appreciated.
From: Eric Lehti To: James Moore
Why not have a last-payment-made field in a file? Update it every time you add a record to your history file. The key to this file would be the entity the payment is going to. Or, if payment history is a history of payments from customers, simply add the last-payment-made field to the Customer Master.
If payment history is a history of payments to vendors, add it to your Vendor Master record.
From: James Moore To: Eric Lehti
That is a very good idea. I guess I'm just trying to find a way to work with what I've got without rewriting major chunks of code. I may have to go to a system like you mentioned though. I think I can get what I need by creating a logical file that is keyed by date in descending order. That way I only have to read the record once and get the last payment made. Your way is much more elegant though. Thanks for the input.
Editor's Note: Another possibility is to create a decimal data area to contain the date of last payment. Data areas are small, inexpensive objects capable of many functions and uses. For more information about data areas, see "The Versatile Data Area" in the February 1993 issue of MC.
LATEST COMMENTS
MC Press Online