View previous topic :: View next topic
|
Author |
Message |
saji123
New User
Joined: 15 Jul 2009 Posts: 19 Location: Chennai
|
|
|
|
I have two sequential file having only one record each, in which the first file contains only the first four digit of telephone number and the second file contains the 10 digit telephonr number. I haev to compare the first for digit of file1 with file2, if it is existing in file2, i have to compare this with the master file which is file3 and have to write all the details of the third file in an output file. Duplication is not there. How can i compare three files, in the loop. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
I have two sequential file having only one record each |
the first compare is simply a YES/NO switch...
read file1 and file2
do the compare, if the compare does not match then exit the program
at this point it is a simple issue of reading the third file an look for a match
if the third file is sorted on the key then You have a less_than/grater_than logic...
if saved key greater than file3 key keep reading
if saved key equal file3 key process the record
if saved key less than file3 key no more records to process
if file3 is not sorted then the stop will be at the end of file3
and the logic will be equal/not equal
i this is not what You intended, the practice a bit on asking questions in the proper way |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
How many records in each file? What is the organization of the master file? Are the files sorted? What have you coded up so far (this is a help forum, after all, not a do it for you forum)? What are you comparing to file 3 -- the 4 digits from file 1 or the 10 digits from file 2? |
|
Back to top |
|
|
saji123
New User
Joined: 15 Jul 2009 Posts: 19 Location: Chennai
|
|
|
|
Sorry i am very much fresher to this field. I will try to post messages in a proper way. To Roberts question. Have to compare the 10 digit and the master file is INDEXED. The files are not sorted.n number of records in each file |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Sort file 1 by all 4 digits.
Sort file 2 by the last 4 digits so file 1 and 2 can be matched easily.
There is a sticky on the COBOL forum with the 2-file match / merge solution. Once the files are sorted, you can use code from the sticky as a starting point. Once you find a match, you can do a direct read to file 3 and output. |
|
Back to top |
|
|
|