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

Querying two flat files on common key in COBOL


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Sun Jun 24, 2007 5:49 pm
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: 8797
Location: Welsh Wales

PostPosted: Sun Jun 24, 2007 6:13 pm
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

Moderator Emeritus


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

PostPosted: Sun Jun 24, 2007 11:00 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
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