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
 

 

Match a file using cobol or easytrieve logic

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
r23051984

New User


Joined: 24 May 2009
Posts: 10
Location: chennai

PostPosted: Thu May 28, 2009 6:30 pm    Post subject: Match a file using cobol or easytrieve logic
Reply with quote

Hi all!

I have two files, input file one, has got duplicates in emp-key which is of 28 bytes
and input file two is not having duplicates of emp key (28 bytes)

I have to match this two files , without using IF MATCHED (if i use easytrieve programming language) condition..like
IF inp1-emp-key = inp2-emp-key


I am not supposed to sort my first input file one on emp-key (28 bytes), Here duplicates are there

I am sorting the second file on emp-key (28 bytes) Duplicates are not here.

So, I cannot use IF MATCHED (if i use easytrieve programming language) condition here

I have to match this two files , (without using IF MATCHED condition)..like
IF inp1-emp-key = inp2-emp-key

and write all the records from both the input files to the output files. (output1)

And if present only in input file1 , i have to write this records to the same first output file (output1)

And if present only in input file2 write to output2

Is there any possibility to code this in COBOL.
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Thu May 28, 2009 6:45 pm    Post subject:
Reply with quote

Quote:
I am not supposed to sort my first input file


what kind of exercise is this? Forced internal table handling?

even if it was an exercise in table handling,
good logic would be sort the file before loading it in the table!!!
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8119
Location: East Dubuque, Illinois, USA

PostPosted: Thu May 28, 2009 6:46 pm    Post subject:
Reply with quote

Without sorting file one, unless it is pretty small, you've got problems. Sort the file and it is a two-file match, for which there's a sticky. Are the duplicates in file 1 together, or are the duplicates scattered throughout the file?

If the duplicates occur together, you could create an indexed file from file 2, read a record from file 1, retain its key for duplicate checking, directly read file 2 to see if the record is there, update file 2 to flag the record as being processed, and output to file 3. After all records in file 1 have been processed, you sequentially process file 2 one time and output to file 4 all records that do not have the flag set.

If the duplicates occur throughout the file, you probably cannot process file 1 successfully unless it is small enough to stay in memory. If file one is small enough, you could build a table in memory of the records and sort it by key, then do the comparisons with file 2.

Sort file 1 and make it easy on yourself.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu May 28, 2009 7:08 pm    Post subject:
Reply with quote

Hello,

Quote:
I am not supposed to sort my first input file one on emp-key (28 bytes),
Sorry to sound harsh, but what in the world determined this "requirement". . . The original file may need to be left in the current sequence, but that should not preclude sorting a copy to use for this match process.

There have been people who posted topics who tried to match files without the files being in sequence and found the job would never end (well not for many days anyway).

Quote:
Is there any possibility to code this in COBOL.
Of course. As mentioned before, there is a "Sticky" near the top of the cobol forum that provides the exact code you need. Both input files must be in sequence. . .
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Thu May 28, 2009 8:19 pm    Post subject:
Reply with quote

This design makes sense and is efficient if file 1 is very large and file 2 is small. Read file 2 and load it into a table in working storage. Then read through file 1 doing a table (search) lookup for each record. This can be done in either COBOL or Easytrieve.
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 SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts UNIT=AFF for Easytrieve code gandikk JCL & VSAM 7 Wed Jul 12, 2017 11:42 pm
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm


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