I want to compare two input files and matching keys from both the files should be written into the output file.
But the input file can have duplicate values in file1 as well as file2. The below code works fine if we have duplicate values from
the input file1 alone.
Key column is: 1,4
//SYSIN DD *
SORT FIELDS=COPY
JOINKEYS FILE=F1,FIELDS=(1,4,A)
JOINKEYS FILE=F2,FIELDS=(1,4,A)
REFORMAT FIELDS=(F1:1,80,F2:1,80)
OUTFIL IFTHEN=(WHEN=INIT,
OVERLAY=(161:SEQNUM,4,ZD,RESTART=(1,4))),
IFTHEN=(WHEN=(161,4,CH,EQ,C'0001'),
BUILD=(1,80,
/,
81,80)),
IFTHEN=(WHEN=NONE,
BUILD=(1,80))
/*
Input File1
1000 ARUN A
1001 BALA B
1001 BALA D
1001 AAAA D
1001 BBBB D
1007 CHAN C
Input file2:
1001 BALA 1
1003 KATE 2
1001 JOHN 5
1004 EDWIN 3
Output:
1001 BALA B
1001 BALA 1
1001 BALA B
1001 BALA D
1001 BALA D
1001 AAAA D
1001 AAAA D
1001 BBBB D
1001 BBBB D
Expected output:
1001 BALA B
1001 BALA D
1001 AAAA D
1001 BBBB D
1001 BALA 1
1001 JOHN 5
SORT FIELDS=COPY
JOINKEYS FILE=F1,FIELDS=(1,4,A)
JOINKEYS FILE=F2,FIELDS=(1,4,A)
REFORMAT FIELDS=(F1:1,80,F2:1,80)
OUTFIL IFTHEN=(WHEN=INIT,
OVERLAY=(161:SEQNUM,4,ZD,RESTART=(1,4))),
IFTHEN=(WHEN=(161,4,CH,EQ,C'0001'),
BUILD=(1,80,
/,
81,80)),
IFTHEN=(WHEN=NONE,
BUILD=(1,80))
/*
Input File1
1000 ARUN A
1001 BALA B
1001 BALA D
1001 AAAA D
1001 BBBB D
1007 CHAN C
Input file2:
1001 BALA 1
1003 KATE 2
1001 JOHN 5
1004 EDWIN 3
Output:
1001 BALA B
1001 BALA 1
1001 BALA B
1001 BALA D
1001 BALA D
1001 AAAA D
1001 AAAA D
1001 BBBB D
1001 BBBB D
Expected output:
1001 BALA B
1001 BALA D
1001 AAAA D
1001 BBBB D
1001 BALA 1
1001 JOHN 5
Can anyone please tell me where to modify to control card to get the desired result. Or is there any alternate way to get the expected output using JCL?
Thanks much.