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

compare two files


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

New User


Joined: 24 Sep 2009
Posts: 2
Location: chennai

PostPosted: Tue Sep 29, 2009 9:05 pm
Reply with quote

Hi,

I have compared two files(file1 & file2) and wrote the matched records in an sepearte file. Now adding to this i need to do write an unmatched records in seperate file and compare those records with file1 in next run of the job. Each time the job runs the files(file1 & file2) input will be changed.

can any one please help me in cobol part of this prg ?

Eg
file1 - cust file
file2 - addr file

both have common cust no.

i have sorted with that key

read cust file into cust rec
read addr file into addr-rec

if cust-no < ad-cust-no
display ' no match addr recd for custno'
if cust-no > ad-cust-no
display 'no custno match for ad-custno'
move cust-rec to out-rec

i m writing my output file. ths s my actual code .

how to change this accoring to my requirement?
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Wed Sep 30, 2009 4:38 pm
Reply with quote

There is a "sticky" in the "Mainframe COBOL" part of the Forum (2-File Match/Merge sample code) -- unload(download?) that, please have a look there and make changes accroding to that. If you get stuck, please post us back with what you've tried and what error did you get.
Back to top
View user's profile Send private message
mambopras

New User


Joined: 11 Nov 2008
Posts: 52
Location: Hyderabad

PostPosted: Wed Sep 30, 2009 9:18 pm
Reply with quote

Hi Saravanan,
i am giving a try at the requirement u have. But we need to know unmatched form which file should be written..file1 or file2? Assuming it to be file1 i am giving u the code.

Note :Both file 1 and file 2 should be sorted before coming to this program. The the below logic might work

if cust-no < ad-cust no
Read File1
Write un-matched-rec from cust-rec
Else
If cust-no > ad-cust-no
Read file2
Else
If cust-no = ad-cust-no
Write matched-rec from cust-rec
Read file1
end-if
end-if
end-if.
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: Wed Sep 30, 2009 9:41 pm
Reply with quote

Hello,

Quote:
The the below logic might work
And it might not. . . (Won't, i believe)

Please post only solutions that have been comprehensively tested. . .
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu Oct 01, 2009 2:16 pm
Reply with quote

you'll need to read file2 as well when matched.
and then the code will only work when each cust-no is unique in both files.
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 Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts How to append a PS file into multiple... JCL & VSAM 3
Search our Forums:

Back to Top