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: 8154
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: 1243
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: 1243
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 Comparing 2 Files using Current time arunsoods SYNCSORT 9 Fri Sep 22, 2017 6:00 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts JES2 job size field matching Windows ... SRICOBSAS All Other Mainframe Topics 4 Tue Sep 05, 2017 5:49 pm
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 21 Sun Aug 27, 2017 10:35 pm
No new posts Match two files using multiple keys a... santoshks1987 SYNCSORT 11 Fri Aug 18, 2017 10:50 am

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