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

Compare 3 files in COBOL.


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

New User


Joined: 13 Feb 2008
Posts: 10
Location: Chennai

PostPosted: Sat Oct 02, 2010 12:04 am
Reply with quote

Hi,

I need to compare 3 files in COBOL and if the record is present in all the 3 files i need to write that record in from file1 to file 4. Can anyone please help me..
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sat Oct 02, 2010 12:31 am
Reply with quote

I would suggest using a two file match, the logic for a three way match can get very messy. Just do file1 and file2 to produce a temp1+2 matched file, then do file1+2 and file3 to produce your final matched file. There is a 2 file match program available in the forum.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Sat Oct 02, 2010 1:39 am
Reply with quote

I know you said Cobol is the requirement, but I think it would be much easier using a Sort utility.

Ask the person you set the cobol requirement if Sort is acceptable.

Is in not about the results, not the method used?
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: Sat Oct 02, 2010 3:02 am
Reply with quote

Hello and welcome to the forum,

If the ONLY processing requirement is matching the keys from the 3 files, using your sort product might be easier. . . If the code requires other than the simply matching code (most/many requirements involve more than the simply match), then writing code is probably a better solution.

Near the top of the COBOL part of the forum is a "Sticky" that contains working code to accomplish a 2-file match/merge. You cluld clone this twice to first merge your file1+2 and then merge this output against file3 to generate file4.
Back to top
View user's profile Send private message
venkatesh shanmugam

New User


Joined: 13 Feb 2008
Posts: 10
Location: Chennai

PostPosted: Sat Oct 02, 2010 12:29 pm
Reply with quote

Thank you all.... They are more specific about comparing through COBOL... I have tried coding as d.sch suggested .... But I have problem while comparing third file... I don't have access to mainframes.com in my workplace... so I 'll post the code tomorrow whichever i wrote....
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: Sat Oct 02, 2010 8:00 pm
Reply with quote

Hello,

Quote:
But I have problem while comparing third file...
If the code works for file1 & file2, a very similar clone will match the 3rd file with the output from the first match. It will take 2 bits of code, not 1.

In additon to (or instead of) posting a lot of code "the problem" needs to be posted. Show a bit of sample input and the desired output from that sample input. SHow what is actually happening that is not wanted.
Back to top
View user's profile Send private message
venkatesh shanmugam

New User


Joined: 13 Feb 2008
Posts: 10
Location: Chennai

PostPosted: Sun Oct 03, 2010 11:54 pm
Reply with quote

Hi,

I have found out the problem and rectified it... and now it is working fine.... thank you d.sch for valuable suggestions.... how to attach the doc while replying ?[/url][/code]
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: Mon Oct 04, 2010 12:12 am
Reply with quote

Good to hear it is working - thank you for letting us know icon_smile.gif

It is better to copy/paste "things" rather than use attachments. Many of our members are not permitted to download these attachments due to security rules on their systems.

d
Back to top
View user's profile Send private message
venkatesh shanmugam

New User


Joined: 13 Feb 2008
Posts: 10
Location: Chennai

PostPosted: Mon Oct 04, 2010 1:00 am
Reply with quote

Ok dick scherrer.... But i have ftp the whole code... since i don't have access to the site in my office... which book can i refer if i need to know about cursor ( block, scrllable, ....)...
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: Mon Oct 04, 2010 1:12 am
Reply with quote

Hello,

I do not understand this reply.

Quote:
But i have ftp the whole code...
Do you want to send somthing or recieve something? From where to where?

Quote:
since i don't have access to the site in my office...
While inconvenient, this should not cause any technical proglems. If you want to download something, use the right-click SaveAs/SaveTargetAs to copy the file to a local drive. Then copy it onto a flash drive or e-mail it as an attachment to yourself at some e-addr.

Quote:
which book can i refer if i need to know about cursor ( block, scrllable, ....)...
Is this a new question or is this related to the question of merging files? It sounds (to me) like database. . .
Back to top
View user's profile Send private message
venkatesh shanmugam

New User


Joined: 13 Feb 2008
Posts: 10
Location: Chennai

PostPosted: Mon Oct 04, 2010 2:42 pm
Reply with quote

Hi d.sch,

For the first one... i meant that i have already ftp the code so can i attach it for viewing... So u can give me advice how to do it effectively...

For the last one... I shouldn't have asked the question in this post... sorry for that..
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Mon Oct 04, 2010 3:20 pm
Reply with quote

a mild warning concern

the program belongs to Your employer,
( developed on the employer equipment and employer time )

You should check about property, copyright and IP issues

even just posting it to have some advice/comment might be in violation of Your employer rules

so for Your wellness watch out icon_biggrin.gif
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: Mon Oct 04, 2010 8:29 pm
Reply with quote

Hello,

Quote:
So u can give me advice how to do it effectively...
I'm not clear on what you want to post? If you use the sample code provided, there should be no need to re-post it icon_confused.gif

Possibly, there is something i misunderstand.

Quote:
For the last one... I shouldn't have asked the question in this post... sorry for that..
Not to worry icon_smile.gif
Has this been posted so that someone can provide an answer?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Mon Oct 04, 2010 8:32 pm
Reply with quote

Hi Dick!
my understanding was that he was trying to load to the forum the program he just developed for the 3 file compare

that the reason for my warning!
Back to top
View user's profile Send private message
venkatesh shanmugam

New User


Joined: 13 Feb 2008
Posts: 10
Location: Chennai

PostPosted: Mon Oct 04, 2010 11:43 pm
Reply with quote

hi,

enrico you are right... i was trying to do the same.... thanks enrico ... U got the point...
Back to top
View user's profile Send private message
venkatesh shanmugam

New User


Joined: 13 Feb 2008
Posts: 10
Location: Chennai

PostPosted: Mon Oct 04, 2010 11:47 pm
Reply with quote

@ d.sch yeah, I have posted that question in DB2 forum..
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 Replace each space in cobol string wi... COBOL Programming 2
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top