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
 

 

Compare 3 files in COBOL.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Compare 3 files in COBOL.
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    Post subject:
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: 645
Location: Pennsylvania

PostPosted: Sat Oct 02, 2010 1:39 am    Post subject:
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

Site Director


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

PostPosted: Sat Oct 02, 2010 3:02 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Sat Oct 02, 2010 8:00 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Mon Oct 04, 2010 12:12 am    Post subject: Reply to: Compare 3 files in COBOL.
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    Post subject:
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

Site Director


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

PostPosted: Mon Oct 04, 2010 1:12 am    Post subject:
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Oct 04, 2010 3:20 pm    Post subject: Reply to: Compare 3 files in COBOL.
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

Site Director


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

PostPosted: Mon Oct 04, 2010 8:29 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Oct 04, 2010 8:32 pm    Post subject: Reply to: Compare 3 files in COBOL.
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    Post subject:
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    Post subject:
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    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 High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am


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