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
 
Querying two flat files on common key in COBOL

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

New User


Joined: 04 Apr 2007
Posts: 17
Location: Chennai

PostPosted: Sun Jun 24, 2007 2:32 pm    Post subject: Querying two flat files on common key in COBOL
Reply with quote

Hi,
The following question was asked in one of the interviews.

Problem statement:
I have two files say FILE1 and FILE2

Contents of FILE1
EmpNo EmpName
1 Latha
2 Mahesh
3 Suresh
7 Ganesh
and so on... Approximately 10 million records in FILE1

Contents of FILE2
EmpNo Salary
2 30000
3 25000
7 18000
9 21000
and so on... Approximately 20 million records in FILE2

I want to get information from both the file where EmpNo is same and write FILE 3, for example
Here the matching EmpNos are 2, 3 and 7
EmpNo EmpName Salary
2 Mahesh 300000
3 Suresh 250000
7 Ganesh 180000

And non-matching records, for example 1 and 9 in above case, should be written to file 4. There should also be EOF handling routine.

Can anyone tell me the procedure division logic.

thanks
Ganesh
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: Sun Jun 24, 2007 5:49 pm    Post subject:
Reply with quote

Hello,

What you are asking about is a called 2-file match/merge) or a "line balance" bit of code. This has been discussed multiple times in the forums (primarliy in COBOL).

Use the search facility and when you find something that you don't understand, please let us know what is your doubt and we will be able to offer suggestions.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8620
Location: Back in jolly old England

PostPosted: Sun Jun 24, 2007 6:13 pm    Post subject:
Reply with quote

Also search the SORT forum, as that offers an alternative solution without having to spend ages writing a program.
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: Sun Jun 24, 2007 11:00 pm    Post subject:
Reply with quote

Hello,

The cobol code shouldn't take any longer than the sort control statements - once there is a working model (which should already exist - IMHO).

Is it good to keep in mind that the only code that should need to be added to a decent model/skeleton is the actual fields for the match and any "other than match" logic required to meet the business requirement.
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 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 Split files upto certain limit based ... bubbu75 DFSORT/ICETOOL 5 Tue Nov 14, 2017 11:11 pm
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am
No new posts Copy selected columns from 2 input fi... Poha Eater DFSORT/ICETOOL 3 Thu Nov 02, 2017 3:43 pm

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