0

I am attempting to write a file matching accounts receivable program. So far I have written the master file that contains the balance of clients and a transaction file that contains the transactions.
But I don't know how to match the account numbers of these files so that i can update the balance. Hope i've explained this ok. Any tips on where to start?

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Ancient Dragon
0

I would assume the transaction file is in no particular order -- rows are appended to the transaction file as they occur, which can be in any order for any given account.

To update the balance in the master file you will have to read the entire transaction file to find all the transactions for a specific account that's located in the master file. When that is done, rewind the transaction file pointer to beginning of file and move on to the next account in the master file.

That could be a fairly lengthly process if the master file has a lot more accounts than in the transaction file. In that case you might want to reverse the process -- start at the beginning of the transaction file, and for each row locate the row in the master file then update its balance.

If the two files are small enough you can start by reading both files into memory arrays, update the balanaces in memory, then rewrite the entire master file.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.