Piscesian Beginner
Joined: 17 Dec 2004 Posts: 14 Topics: 8 Location: Monrovia,California
|
Posted: Sat Dec 10, 2011 6:42 am Post subject: Matching two files on keys and writing to output |
|
|
I have two files
File A - LRECL=250,RECFM=FB
----+----1----+----2
********************
ABCD000000047700012
NPTQ000000047700012
ASRA000000047700012
BECC400124431800001
CASA000128559000001
File B - LRECL=250,RECFM=FB
----+----1----+----2
********************
ABCD000000047700012
NPTQ000000047700012
ASRA000000047700012
Output file should contain unmatched records between File A and File B
Key fields for comparison starts in position 6 of both files and of 9 characters
Is this possible using DFSORT? |
|
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12382 Topics: 75 Location: San Jose
|
Posted: Sat Dec 10, 2011 8:45 am Post subject: |
|
|
Piscesian,
If none of your files have duplicates on the key , then you can use select operator with nodups which will eliminate all the matching records from the both files.
Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=Your input file A,DISP=SHR
// DD DSN=Your input file B,DISP=SHR
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(6,7,CH) NODUPS
//* |
If your input does have duplicates , then use the following DFSORT JCL which will give you the desired results.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD DSN=your input FB 250 byte file A,DISP=SHR
//INB DD DSN=same input FB 250 byte file B,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(6,9,A)
JOINKEYS F2=INB,FIELDS=(6,9,A)
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,250,F2:1,250,?)
OUTFIL IFOUTLEN=250,OMIT=(501,1,CH,EQ,C'B'),
IFTHEN=(WHEN=(501,1,CH,EQ,C'2'),BUILD=(251,250))
//* |
_________________ Kolusu
www.linkedin.com/in/kolusu |
|