View previous topic :: View next topic
|
Author |
Message |
saravanandj
New User
Joined: 24 Sep 2009 Posts: 2 Location: chennai
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
mambopras
New User
Joined: 11 Nov 2008 Posts: 52 Location: Hyderabad
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
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 |
|
|
|