View previous topic :: View next topic
|
Author |
Message |
irene hermia
New User
Joined: 19 Sep 2011 Posts: 2 Location: philippines
|
|
|
|
Hi i am new to cobol and i am having an exercise where i am going to read 2 input file (the balance master file and the transaction file) to produce a new report and at the same time update the balance master file with every transaction... I just want to know which is much better or efficient...reading the two files and compare it or make an internal table (either for the balance master or for the transaction file) and then do a search all.... hope you can help me.. thanks a lot... |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
How many records on each file?
Sounds like you have a basic 2-file match. Have you seen the 2-file match 'sticky' at the top of the cobol section of the forum? Take a copy and modify it to your needs. If you had programming education you must surely have done a 2 file match there - does not matter which language as the priciples are the same. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Make sure both files are sorted on "the key". Then match the 2 files doing whatever is required when they match or do not match.
At the top of the COBOL part of the forum is a sample 2-file match/merge program that will probably work for your requirement. You may need to make a few modifications to do exactly what you want.
Take the time to understand how this code works as you may need a match/merge many times - sometimes the sort product will suffice and sometimes you will need code. |
|
Back to top |
|
|
irene hermia
New User
Joined: 19 Sep 2011 Posts: 2 Location: philippines
|
|
|
|
Hi,
Thanks for your help. I've seen the sample program. But for example I have 2 input file, is it better to read the 2 files and compare it or use an internal table? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If you are going to succed in IT, you need to pay attention. . .
While neither of us said so specifiucally, we both mentoined using a 2-file match/merge. We replied this way because this is the better choice at least 99% of the time.
There is Rarely a reason to load an entire file into an internal array or open/close the file many times (another terrible approach that people ask about).
Quote: |
Thanks for your help. I've seen the sample program. But for example I have 2 input file, |
Yes, we knew this - it is why the code has been provided. . . It also appears that you did not closely look at the rather simple code. |
|
Back to top |
|
|
|