Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
cobol program to compare two seq. files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
Rohit.sun123
Warnings : 1

New User


Joined: 01 Jun 2007
Posts: 1
Location: bangalore

PostPosted: Tue Feb 12, 2008 12:38 pm    Post subject: cobol program to compare two seq. files
Reply with quote

There are 2 sequential files with records. Now we have to check for the matching records in both the files and put matched reords in a output file and unmatched records in a second output file.
Back to top
View user's profile Send private message

srinivas_443

New User


Joined: 19 Dec 2007
Posts: 11
Location: chennai

PostPosted: Tue Feb 12, 2008 12:57 pm    Post subject: Reply to: cobol program to compare two seq. files( five lakh
Reply with quote

Using cobol program we can do.

First open 2 file
Read file1(first rec)
Move record to WS-area1
Read file 2(first rec)
Move record to WS-area2

If WS-area1=WS-area2
Write to match-rec-file
Else
Write to diff-rec-file


This is my thought
Correct me if I am wrong


Regards,
Srinivas Jala
Back to top
View user's profile Send private message
ashwinreddy

Active User


Joined: 16 Sep 2004
Posts: 106
Location: Hyderabad

PostPosted: Tue Feb 12, 2008 3:42 pm    Post subject:
Reply with quote

Hi Srinivas,

The above solution holds good for after sorting both the files with equal number of records in both the files.

Let me give you an example

file 1 file 2

1 3
2 1
3 4

If the files are in above format, then you may miss some records (almost all).

Slight modification in Srinivas logic


First open 2 file
Read file1(first rec)
Move record to WS-area1
Read file 2(first rec)
Move record to WS-area2

If WS-area1=WS-area2
Write to match-rec-file
Else

Perform the 2nd file read until match found with the first file

If match found
Write to match-rec-file
Else
Write to diff-rec-file
End-if
End-if

I can see some redundant code in above logic, but i think tat will be corrected by prasad


Please correct me if i am wrong.

Cheers
Ashwin
Back to top
View user's profile Send private message
srinivas_443

New User


Joined: 19 Dec 2007
Posts: 11
Location: chennai

PostPosted: Tue Feb 12, 2008 4:38 pm    Post subject:
Reply with quote

Hi Ashwin

Good idea.Thanks
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Feb 12, 2008 7:01 pm    Post subject:
Reply with quote

Hi,

Well, for such a file matching Logic, don't You think.. both the files should be in sorted order (ofcourse on the same key). BTW, this topic has been discussed many times, please search.

There is a sticky in Mainframe COBOL Forum by Dick for a file matching program. Use that to give You a start & change the code as per Your needs..here is the link.
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: Tue Feb 12, 2008 10:11 pm    Post subject:
Reply with quote

Hello,

Quote:
This is my thought
Correct me if I am wrong
Yes, the posted code will not work.

Quote:
The above solution holds good for after sorting both the files with equal number of records in both the files.
Even if the files are sorted and have the same number of records, the compare will not work correctly.

Quote:
There is a sticky in Mainframe COBOL Forum by Dick for a file matching program
As suggested by Anuj, i'd recommend reviewing the code at the "sticky" and post any questions about it here. We can clarify any doubts.
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 -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts The same REXX program doesnt work for... jackzhang75 CLIST & REXX 5 Wed Dec 06, 2017 2:51 am
No new posts Compare VSAM files using DFSORT pshongal DFSORT/ICETOOL 5 Thu Nov 23, 2017 10:24 am
This topic is locked: you cannot edit posts or make replies. Cobol to fetch the content by using s... arunc55 COBOL Programming 4 Fri Nov 17, 2017 1:25 pm
No new posts Compare and COPY using DFSORT pshongal DFSORT/ICETOOL 3 Fri Nov 17, 2017 9:49 am
No new posts Calling IKJEFT01 program from Rexx upendrasri CLIST & REXX 8 Wed Nov 15, 2017 4:27 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us