File Operation (Asked in IBM)



File Operation (Asked in IBM)

Postby rakaitn » Wed Sep 29, 2010 8:12 pm

There are two huge files, let's say FILEA and FILEB.

Objective is:

1) Read FILEA first and if the same record is found in FILEB, write it into FILE01 and if not found write it into FILE02. This process has to continue till the end-of-file of FILEA.

2) Once FILEA completely read, then write a line full of ' ***** ' in FILE01 as well as FILE02

3) Then start reading FILEB and find the record in FILEA. If found write into FILE01, not found write into FILE02. Continue till end-of-file of FILEB.

Interviewer asked me to write a cobol code (just structure) to achieve the above - I have written the lengthy approach first -
Sort FILEA, FILEB
Read FILEA, Find in FILEB
Write to FILE01/FILE02.

He agreed that it will give appropriate result but would be very inefficient taking long time as records may be millions.

Kindly suggest how to achieve the above efficiently. (using JCL and COBOL only).
rakaitn
 
Posts: 2
Joined: Wed Sep 29, 2010 7:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: File Operation (Asked in IBM)

Postby dick scherrer » Thu Sep 30, 2010 12:59 am

Hello,

At/near the top of the COBOL part of the forum is a "Sticky" of working code that will do a 2-file match/merge (which is what you want if i understand the question).

Once both files are sorted, this code will do what you want in one pass of the files comparing them as it goes.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: File Operation (Asked in IBM)

Postby rakaitn » Thu Sep 30, 2010 10:17 am

Hi,

Extremely sorry, I didn't get what you were trying to state.

Could you please elaborate a bit.
rakaitn
 
Posts: 2
Joined: Wed Sep 29, 2010 7:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: File Operation (Asked in IBM)

Postby NicC » Thu Sep 30, 2010 10:46 pm

Dick is trying to state that there is sample, working, code in the COBOL part of the forum. It is about the first or second topic in that section. It is called a 'sticky' because it sticks in that place because new topics are placed after all stickies. Take a look and you will see.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: File Operation (Asked in IBM)

Postby dick scherrer » Fri Oct 01, 2010 1:41 am

Hello,

Click on "Board index" near the top left of the screen.

Then click on IBM Cobol.

Then click on the 2-file match/merge "sticky".
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to Interview Questions

 


  • Related topics
    Replies
    Views
    Last post