View previous topic :: View next topic
|
Author |
Message |
mitaljalu
New User
Joined: 26 May 2006 Posts: 7 Location: india
|
|
|
|
Hi,
i have two input files and i have to write those records to the output files which are similar in both input files.
can anybody help me? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You need to post some details.
Show some sample data from your input files and what you want the output(s) to be from that input. |
|
Back to top |
|
|
mitaljalu
New User
Joined: 26 May 2006 Posts: 7 Location: india
|
|
|
|
data can be anything like
INPUT FILES
File-1 File-2
1abc 8ghi
2def 9pqr
8ghi 5xyz
4lrn 1abc
Suppose above two files are there and have two common records 8ghi and 1abc , so output file should contains only these two records
OUTPUT FILE
File-3
1abc
8ghi |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Are you trying to match the entire record or is what you've shown the "key" for the records? How many records are in the files? What is the length of each file (lrecl)?
You also need to decide what to do with "duplicates" in either file whether they be duplicate keys or entire records.
Regardless of the above answers, the process is usually:
First, you need to get both files into the same sequence (easiest way is to run a sort for each file.
Next, match the 2 sorted files against each other, discarding all of the non-matching records depending on what business rulles (other than matching) need to be implemented, you could also do what you want with your sort product.
Please spend a little time creating a more complete example. |
|
Back to top |
|
|
cvadlamudi
New User
Joined: 19 Apr 2007 Posts: 68 Location: India
|
|
|
|
Hi,
If u want to go with cobol u can go as per dick scherrer and also there is an option using JCL with SPLICE in ICETOOL. |
|
Back to top |
|
|
Shrimathi Krishnan
New User
Joined: 19 Apr 2007 Posts: 39 Location: Chennai
|
|
|
|
can u please explain me wat us ICETOOL and how we can use it.. wat is SPLICE in ICETOOL |
|
Back to top |
|
|
ashwinreddy
Active User
Joined: 16 Sep 2004 Posts: 106 Location: Hyderabad
|
|
|
|
Hi,
If you want to just compare the two files then best method is to use the Sort in JCL as dick mentioned.
Else if your requirement is to compare the two files in cobol then you can do that by taking two group level working stoage variables as file1 and file2
Read both files and save the record in working storage variables(file1 and file2), compare both the variables keeping one constant and varing the other until end of the file.
And when match found write into other file.
And some one asked about the ICETOOL
ibmmainframes.com/viewtopic.php?t=1348
If you ask me then the solution which dick has suggested is best one, rather than going for cobol program.
Cheers
Ashwin |
|
Back to top |
|
|
vkphani
New User
Joined: 29 Oct 2003 Posts: 29
|
|
|
|
The below JCL will solve your problem.
Code: |
//S1 EXEC PGM=ICETOOL
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD *
1ABC
2DEF
8GHI
4LRN
8GHI
9PQR
5XYZ
1ABC
//TOOLIN DD *
SELECT FROM(CON) TO(OUT1) ON(1,4,CH) ALLDUPS USING(CTL3)
/*
//CTL3CNTL DD *
OUTFIL FNAMES=(OUT1,OUT2),SPLIT
/* |
Concatenate your two input files in the DD statement CON. |
|
Back to top |
|
|
Vinit Bhushan
New User
Joined: 17 Apr 2007 Posts: 4 Location: Gurgaon
|
|
|
|
Hi Mital How are You?
This JCL may also Help.
//STEP10 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=&SYSCLS
//DFSMSG DD SYSOUT=&SYSCLS
//IN1 DD DSN=,DISP=SHR
//IN2 DD DSN=,DISP=SHR
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(1,1)),
// DISP=(MOD,PASS)
//OUT12 DD DSN=,DISP=SHR
//OUT1 DD DSN=,DISP=SHR
//OUT2 DD DSN=,DISP=SHR
//TOOLIN DD DSN=DISP=SHR
//CTL1CNTL DD DSN=,DISP=SHR
//CTL2CNTL DD DSN=,DISP=SHR |
|
Back to top |
|
|
mitaljalu
New User
Joined: 26 May 2006 Posts: 7 Location: india
|
|
|
|
Thanks to all. i have done. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
That's good news
It may help others to see how you implemented your solution.
Which solution did you use? |
|
Back to top |
|
|
munikumar Currently Banned New User
Joined: 18 Apr 2007 Posts: 24 Location: India
|
|
|
|
Another way is using SORT.
Code: |
//STEP EXEC PGM=SORT
//SORTIN DD DSN=A.DSN,DISP=SHR
// DD DSN=B.DSN,DISP=SHR
//SORTOUT DD DSN=C.DSN,
// DISP=(NEW,CATLG,DELETE),
// UNIT=,
// SPACE=,
// DCB=
//SORTXSUM DD DSN=D.DSN,
// DISP=(NEW,CATLG,DELETE),
// UNIT=,
// SPACE=,
// DCB=
//SYSIN DD *
SORT FIELDS=(1,4,CH,A)
SUM FIELDS=NONE,XSUM
/*
// |
XSUM will get all the matched records from file1 & file2 and writes into SORTXSUM file.
Note: This SORTXSUM file will now have duplicates only. (Loosely speaking)
A.DSN B.DSN
------- --------
1abc 8ghi
2def 9pqr
8ghi 5xyz
4lrn 1abc
D.DSN
--------
1abc
8ghi |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Thank you for posting your solution |
|
Back to top |
|
|
mitaljalu
New User
Joined: 26 May 2006 Posts: 7 Location: india
|
|
|
|
Hi Dick,
I uesed first solution. Sort both the files and just compare records of both files.
Even i have also tested other solution that is using ICETOOL |
|
Back to top |
|
|
|