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).
File Operation (Asked in IBM)
- dick scherrer
- Global moderator
- Posts: 6268
- Joined: Sat Jun 09, 2007 8:58 am
Re: File Operation (Asked in IBM)
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.
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.
d.sch.
-
- 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)
Hi,
Extremely sorry, I didn't get what you were trying to state.
Could you please elaborate a bit.
Extremely sorry, I didn't get what you were trying to state.
Could you please elaborate a bit.
-
- 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)
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
Regards
Nic
- dick scherrer
- Global moderator
- Posts: 6268
- Joined: Sat Jun 09, 2007 8:58 am
Re: File Operation (Asked in IBM)
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".
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.
d.sch.
-
- Similar Topics
- Replies
- Views
- Last post
-
-
EZIOE004 Logical I/O error on file occurred reading VB file
by savitha_y » Mon Feb 15, 2021 7:54 pm » in CA-Easytrieve - 3
- 4956
-
by savitha_y
View the latest post
Wed Feb 17, 2021 5:02 am
-
-
-
File Handling 3 input files and 1 output file by using EZT
by pavan426 » Thu Sep 09, 2021 12:17 am » in CA-Easytrieve - 0
- 4415
-
by pavan426
View the latest post
Thu Sep 09, 2021 12:17 am
-
-
-
Need to check whether file is ESDS file or not by using REXX
by Devrana » Sat Oct 05, 2024 2:28 pm » in CLIST & REXX - 6
- 3109
-
by sergeyken
View the latest post
Tue Oct 08, 2024 5:25 pm
-
-
- 6
- 2488
-
by MFDEV
View the latest post
Fri Sep 11, 2020 9:04 am
-
- 2
- 4923
-
by chaat
View the latest post
Thu Jan 28, 2021 12:09 am