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

Reading and matching 3 sequential files


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dunkinjonats

New User


Joined: 14 Aug 2008
Posts: 2
Location: Philippines

PostPosted: Wed May 13, 2009 6:18 pm
Reply with quote

Hi,

I'm a newbie here and just starting to learn about cobol.

I need to extract records from 3 sequential files namely CURRENT, INSURANCE and ACCOUNTS files.

The first file that needs to be read is the CURRENT file until EOF then look for its matching records in INSURANCE and ACCOUNTS files using the ACCOUNT-NO.

Can someone help me on how to do read and match files?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed May 13, 2009 6:28 pm
Reply with quote

Quote:
The first file that needs to be read is the CURRENT file until EOF then look for its matching records
This makes absolutely no sense -- why would you read until end-of-file on a file you're trying to match records on?

One possibility: ensure the files are sorted and use the two-file match provided in the sticky against two of your files to produce a temporary file that is then matched against the third file in a second application of the same technique.

Or, take the two-file solution and generalize it by adding the third file logic. This definitely gets trickier though since instead of three key conditions to worry about you have 9 to think through.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Wed May 13, 2009 6:40 pm
Reply with quote

Hi dunkinjonats !

You could also achieve this by using the SORT utility.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu May 14, 2009 2:10 am
Reply with quote

Basically, you have one loop on the main file.
There are few methods for doing this, maybe your shop has standards.
The code in the loop will be executed once for each record in CURRENT.
This code will contain access to the 2nd and 3rd file, then will get a new record for the next pass:
Code:
    PERFORM F10-READ-FIRST-CURRENT
    PERFORM UNTIL FLAG-EOF-CURRENT
        DISPLAY 'PROCESSING ACCOUNT NUMBER ' ACCOUNT-NO OF CURRENT
        PERFORM F30-READ-INSURANCE-BY-KEY
        PERFORM F40-READ-ACCOUNTS-BY-KEY
        PERFORM D10-DO-MAIN-THING
        PERFORM F20-READ-NEXT-CURRENT
    END-PERFORM
When you reach D10 for the 1st time, you have in W-S the 3 records:
CURRENT (from F10), INSURANCE (from F30) and ACCOUNTS (from F40).
After that, you reach D10 again but with another CURRENT record (from F20) with new matching companions.

FLAG-EOF-CURRENT is set to true in the AT END clause in F10 and F20.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu May 14, 2009 2:27 am
Reply with quote

Keep this page bookmarked (seriously, you will need it. Print it if you can, too).
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
Search our Forums:

Back to Top