IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Move records if inputfile1's record match with inputfile2's


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
LinkinPark
Warnings : 1

New User


Joined: 20 Nov 2005
Posts: 44
Location: DALIAN,CHINA

PostPosted: Fri Aug 31, 2007 6:57 am
Reply with quote

Hi all,

If there r 2 files,

1st file records are(named inputfile1):
1
3
5

2nd file records are(named inputfile2): :
1
2
4
5
7
8

Can anybody show me how to code below requirement ?
1) if inputfile1's record match with inputfile2's record, move record to output file1
2) if records only included in inputfile1, move record to output file2
2) if records only included in putfile2, move record to output file3
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Aug 31, 2007 7:43 am
Reply with quote

Hello,

What you describe is a 2-file match/merge. If you look at the "Sticky" near the top of this COBOL forum, there is sample code you can download.

If, after downloading the sample code, yoj have questions, post them here.

You will need to customize the code depending on your specific requirement.
Back to top
View user's profile Send private message
LinkinPark
Warnings : 1

New User


Joined: 20 Nov 2005
Posts: 44
Location: DALIAN,CHINA

PostPosted: Fri Aug 31, 2007 12:54 pm
Reply with quote

I've go thru the code u mentioned,
but it seems just 1st requriement implemented,
how abt requirement 2) and 3),
What I wanna do is implement above 3 requriements in just one procedure or a program, just open/close all file onetime! icon_biggrin.gif
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Fri Aug 31, 2007 2:57 pm
Reply with quote

That's the neat thing about programming, you can change and/or add logic to do whatever you want....
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Aug 31, 2007 7:04 pm
Reply with quote

Hello,

Quote:
You will need to customize the code depending on your specific requirement.
If you add just the smallest bit of code to the example, you will meet all of your requirements.

The "match" is what you really needed guidance on. The rest is just some simple open, move, write, & close statements. There should remain only 1 procedure. 1 open/close, and the files passed 1 time.

If you get stuck, post what you have done and where you have a question and someone here will be able to help.
Back to top
View user's profile Send private message
LinkinPark
Warnings : 1

New User


Joined: 20 Nov 2005
Posts: 44
Location: DALIAN,CHINA

PostPosted: Sat Sep 01, 2007 4:29 am
Reply with quote

Hi ,

As my understanding, it works well.but what about below 2 files.
1st file records are(named inputfile1):
1
3
3
5
5
6
6
9
9

2nd file records are(named inputfile2):
1
2
4
5
5
5
5
7
8

Above 2 files with duplicate key.

requirement :
1) if inputfile1's record match with inputfile2's record, move record to output file1 , ( 1 to n matched).
2) if records only included in inputfile1, move record to output file2
2) if records only included in putfile2, move record to output file3
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Sep 01, 2007 7:18 am
Reply with quote

Hello,

Duplicate keys in either or both files will be handled by the code.

In the simplest case, the first of each duplicate is processed like any other match and the code continues.

Before you can implement any code you have to formalize the "rules" for your process. We can't help with the rule definition - that is based on your particular requirement.

In your example data there are two 5's (let's call them 5a and 5b) in file 1 and 4 5's in file2 (let's call them 5w, 5x 5y, and 5z). Which ones should go to which output file(s)?

Before you can implement a COBOL (or any other) solution, you must completely define what is to happen for each and every condition.

Notice that when you posted your second set of data, you added "new rules". Before writing code, you will need to define everything that the code is to support.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top