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
 

 

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: 8593
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
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am


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