View previous topic :: View next topic
|
Author |
Message |
ganeshptrk
New User
Joined: 04 Apr 2007 Posts: 17 Location: Chennai
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Also search the SORT forum, as that offers an alternative solution without having to spend ages writing a program. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|