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
 

 

COBOL match file algorithm

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

New User


Joined: 07 Mar 2007
Posts: 40
Location: India

PostPosted: Sat Jul 16, 2011 10:25 am    Post subject: COBOL match file algorithm
Reply with quote

Hi All,
I have a match file requirement where my files can be in the below format

File 1
field1 field2
111 AAA
222 AAA
222 AAA
333 AAA
444 BBB
555 BBB
666 BBB
666 BBB

File 2
Field1 Field2
222 AAA
222 AAA
555 BBB
888 BBB

Many combinations of this files can exist
basically i should read all the records of file 1 with the same field1 and field2 combination and then process the file 2 records one by one which has the same combination

Processed until one of the file is read completely

Can any one help me with the algorithm for this requirement?
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: Sat Jul 16, 2011 10:30 am    Post subject:
Reply with quote

Hello,

At the top of this COBOL part of the forum is a "Sticky" with working code to do nearly what you want.

With only a little modification, you can do what you want using this (unless i misunderstand what you want to do).
Back to top
View user's profile Send private message
Deepthy Jose P

New User


Joined: 07 Mar 2007
Posts: 40
Location: India

PostPosted: Sat Jul 16, 2011 10:42 am    Post subject:
Reply with quote

Thanks Dick,
I read the sticky, but it seems to be a normal file compare, my requirement is a bit different as i have to read the same "key"(not a unique one but same field1 and field2 combinations) from file 1 and then from file2 find the same combination records one by one
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: Sat Jul 16, 2011 10:47 am    Post subject:
Reply with quote

Hello,

Suggest you more closely look at your requirement and the posted code. From what you have posted so far, the sample code should be able to get very close. . .

You need to explain why you believe the simple solution will not work for your case.

You (or someone) has arbitrarily made a "processing requirement" that may complicate the implementation. Why can the 2 "keys" not be concatenated and treated as one and then the files matched?
Back to top
View user's profile Send private message
Deepthy Jose P

New User


Joined: 07 Mar 2007
Posts: 40
Location: India

PostPosted: Sat Jul 16, 2011 10:57 am    Post subject:
Reply with quote

File 1 has another field which has some specific text values for which we have to analyse multiple fields values from file 2 (could be in any order) and then write the file 2 record as output if a match is found

Let me give an example

File 1

field1 field2 field 3
111 aaa text1
111 aaa text2
111 aaa text3

file 2

field1 field2 field 3 to field n
111 aaa records matching to text 3
111 aaa records matching to text 1


basically the files cannot be sorted to have it as a sequentiall search so we have to read all teh records from file 1 for 111 and aaa and set the flags for the text1 text 2 and text 3 and then read one by one record from file 2 and look for whether all the field values(field3 to field n) corresponds to any of the text 1 text2 or text 3 conditions
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: Sat Jul 16, 2011 11:08 am    Post subject:
Reply with quote

Hello,

Suggest you take a bit of time and post some "close to real" data and the output wanted from the sample data. Real-world data is easier for many to relate to than alphabet-soup and "textn" values. I also believe that your "file 2" looks like some kind of output rather than the second input.

When posting this new data, please use the "Code" tag to preserve alignment and improve readability. Use Preview to see your post as it will appear to the forum and Submit when the post appears as you want.

If i understand at all, there should be 3 files and there is no reason for anyone here to "figure it out".
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Sat Jul 16, 2011 1:27 pm    Post subject:
Reply with quote

Deepthy Jose P,

1. you never reread files.

2. you always presort the files in the matching sequence.

3. learn to pose you questions with all the requriements.
stop trying to sandbag us with
'well there is another requirement which justifies my approach'
in a subsequent post.

4. if this is a school assignment to learn how to use COBOL Internal Tables,
say so,
because otherwise this is just a two file match merge,
no matter what 'big' words you misuse to describe you situation.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Sat Jul 16, 2011 2:02 pm    Post subject: Reply to: COBOL match file algorithm
Reply with quote

As dbz says, pre-sort the files. If you need them back in the original order afterwards, add a sequence number. After your processing, sort on the sequence number and strip it off.

With duplicates on both files, I use what I call a "sideways" match. Look at what you have written, you already have it - as long as the files are sorted.
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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am


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