File Operation (Asked in IBM)

rakaitn
Posts: 2
Joined: Wed Sep 29, 2010 7:51 pm
Skillset: COBOL, DB2, JCL, VSAM, CICS
Referer: IBMMAINFRAMES.COM

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).

User avatar
dick scherrer
Global moderator
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am

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.

rakaitn
Posts: 2
Joined: Wed Sep 29, 2010 7:51 pm
Skillset: COBOL, DB2, JCL, VSAM, CICS
Referer: IBMMAINFRAMES.COM

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.

NicC
Global moderator
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
Referer: Google
Location: Pushing up the daisies (almost)

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

User avatar
dick scherrer
Global moderator
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am

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.


  • Similar Topics
    Replies
    Views
    Last post