Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Reading and matching 3 sequential files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Reading and matching 3 sequential files
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: 7999
Location: Bellevue, IA

PostPosted: Wed May 13, 2009 6:28 pm    Post subject:
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: 755
Location: Germany

PostPosted: Wed May 13, 2009 6:40 pm    Post subject:
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: 1226
Location: Israel

PostPosted: Thu May 14, 2009 2:10 am    Post subject:
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: 1226
Location: Israel

PostPosted: Thu May 14, 2009 2:27 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Matching and unmatching records scdinesh DFSORT/ICETOOL 11 Tue Feb 07, 2017 12:41 am
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 15 Thu Dec 01, 2016 8:28 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us