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

Comparing records in two files and check if record present


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

New User


Joined: 27 Jul 2006
Posts: 10

PostPosted: Fri Jan 05, 2007 4:48 pm
Reply with quote

my problem is I have two input files(with thousands of records), I need to compare both the files and check if the record present in first file is present in second file or not.

Can you suggest me the procedure to do this?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jan 05, 2007 5:07 pm
Reply with quote

There are several threads on the sort forum showing how that can be done with sort.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jan 05, 2007 6:14 pm
Reply with quote

athiqmsr wrote:
all the fields in my first record are not same in the second records, so I have to select only some key fields, I think this can be done only thru' program.

My problem is I have two files, I have to read first record in the first file & compare with the records in the second file, if the record is present I ve to write, If not I ve to read the second record in file1 & continue the process.
Can you give me sample code for this?
Is there a field or fields in the first file that are the same (not so much position but content) in the second file? You read file1 and read file2 and if afield1 = a field2 and bfield1 = b field2 then write else read file2 again and go back and compare?
Back to top
View user's profile Send private message
abhijeet3162002

New User


Joined: 05 Jul 2004
Posts: 6
Location: mumbai

PostPosted: Fri Jan 05, 2007 6:17 pm
Reply with quote

What kinda files you are using?

If Files are KSDS your job will get simplified.
Read 1st KSDS sequentially and for every read, take a record key of first
file and randomly search for the key in second file.

If you are using ESDS files (or flat files). Read first file sequentially and after every read of first file, read second file till end of records or till you found the matching records.

Let me know if I am not clear...

Cheers
Back to top
View user's profile Send private message
athiqmsr
Warnings : 2

New User


Joined: 27 Jul 2006
Posts: 10

PostPosted: Fri Jan 05, 2007 8:47 pm
Reply with quote

Thanks Abhijeet,
I am using sequential files.
I am trying your method, but facing some problem, can you give me sample code for the same.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jan 05, 2007 8:58 pm
Reply with quote

athiqmsr wrote:
all the fields in my first record are not same in the second records, so I have to select only some key fields, I think this can be done only thru' program.

My problem is I have two files, I have to read first record in the first file & compare with the records in the second file, if the record is present I ve to write, If not I ve to read the second record in file1 & continue the process.
Can you give me sample code for this?
Is there a field or fields in the first file that are the same (not so much position but content) in the second file? You read file1 and read file2 and if afield1 = a field2 and bfield1 = b field2 then write else read file2 again and go back and compare?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jan 05, 2007 9:30 pm
Reply with quote

Hello,

Suggest that you get both files in the same sequence - by whatever it is you want to compare (i.e. account-no or ssn or "the whole record", or?).

When you have the files in sequence, you can do what you want with sort (as others have mentioned).

If you look in the dfsort forum, you will find solutons - but they will require the data be "in order".

If one or both files are VSAM but not in the order you need for comparison, i'd suggest getting the data in sequential files and then proceeding.
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 Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top