IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Comparing three Sequential file


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
saji123

New User


Joined: 15 Jul 2009
Posts: 19
Location: Chennai

PostPosted: Wed Jul 15, 2009 8:00 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jul 15, 2009 8:11 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Jul 15, 2009 8:11 pm
Reply with quote

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
View user's profile Send private message
saji123

New User


Joined: 15 Jul 2009
Posts: 19
Location: Chennai

PostPosted: Wed Jul 15, 2009 8:31 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Jul 15, 2009 9:08 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top