Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 8201
Location: East Dubuque, Illinois, USA

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: 757
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: 1252
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: 1252
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 ISSUE IN copying Sequential file reco... thesumitk JCL & VSAM 2 Wed Dec 13, 2017 3:07 pm
No new posts Compare VSAM files using DFSORT pshongal DFSORT/ICETOOL 5 Thu Nov 23, 2017 10:24 am
No new posts Split files upto certain limit based ... bubbu75 DFSORT/ICETOOL 5 Tue Nov 14, 2017 11:11 pm
No new posts Matching and unmatched records!! Vignesh Sid SYNCSORT 3 Thu Nov 09, 2017 11:22 am
No new posts Copy selected columns from 2 input fi... Poha Eater DFSORT/ICETOOL 3 Thu Nov 02, 2017 3:43 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us