View previous topic :: View next topic
|
Author |
Message |
LinkinPark Warnings : 1 New User
Joined: 20 Nov 2005 Posts: 44 Location: DALIAN,CHINA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
LinkinPark Warnings : 1 New User
Joined: 20 Nov 2005 Posts: 44 Location: DALIAN,CHINA
|
|
|
|
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! |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
That's the neat thing about programming, you can change and/or add logic to do whatever you want.... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
LinkinPark Warnings : 1 New User
Joined: 20 Nov 2005 Posts: 44 Location: DALIAN,CHINA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|