Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Comparing records in two files and check if record present

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Comparing records in two files and check if record present
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: 3158
Location: Tucson AZ

PostPosted: Fri Jan 05, 2007 5:07 pm    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Fri Jan 05, 2007 6:14 pm    Post subject:
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    Post subject: Re: comparing records in two files
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    Post subject: comparing sequential files
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: 3158
Location: Tucson AZ

PostPosted: Fri Jan 05, 2007 8:58 pm    Post subject:
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

Site Director


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

PostPosted: Fri Jan 05, 2007 9:30 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Dynamic split of files under groups sril.krishy DFSORT/ICETOOL 4 Mon Apr 17, 2017 1:09 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us