kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Apr 23, 2009 3:50 pm Post subject: |
|
|
Sqlcode,
The following DFSORT JCL will give you the desired results.
I used these codes to denote the changes
Code: |
NC = No Change ie. ID,AMOUNT,STAGE-1,STAGE-2 all match
CR = Change record i.e id matches but one of AMOUNT,STAGE-1,STAGE-2 doesnt match
NA = New Add ie no matching key in file 2
ND = New Delete i.e No matching key in file 1
|
The logic is quite simple
1. Put a header so as to identify from which file the record came from. Use group function to put a ID in pos 1017.
2. Now if it is from file 2 we put the contents of amount, stage1 and stage-2 in pos 1001.
3. Now sort on the key
4. Sum the contents in pos 1001 and also the ID
5. If there is a match key record the sum will be 3 and now we can compare the 2 records
6. If they dont match the sum will be either 1 or 2. if 1 then it is from file 1 and if 2 then it is from file 2.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=1000 byte header record,DISP=SHR
// DD DSN=1000 byte input file1,DISP=SHR
// DD DSN=1000 byte header record,DISP=SHR
// DD DSN=1000 byte input file2,DISP=SHR
//SORTOUT DD SYSOUT=*
OPTION EQUALS
INREC IFTHEN=(WHEN=INIT,OVERLAY=(1001:16Z)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'HEADER'),PUSH=(1017:ID=1)),
IFTHEN=(WHEN=(1017,1,ZD,EQ,2),OVERLAY=(1001:402,5,542,10))
SORT FIELDS=(023,7,PD,A)
SUM FIELDS=(1001,8,BI,
1009,8,BI,
1017,1,ZD)
OUTFIL IFOUTLEN=1000,OMIT=(1,6,CH,EQ,C'HEADER'),
IFTHEN=(WHEN=(1017,1,ZD,EQ,1),OVERLAY=(101:C'NA')),
IFTHEN=(WHEN=(1017,1,ZD,EQ,2),OVERLAY=(101:C'ND')),
IFTHEN=(WHEN=(1017,1,ZD,EQ,3,AND,
0402,5,PD,EQ,1001,5,PD,AND,
0542,5,CH,EQ,1006,5,CH,AND,
0547,5,CH,EQ,1011,5,CH),
OVERLAY=(101:C'NC')),
IFTHEN=(WHEN=(1017,1,ZD,EQ,3,AND,
0402,5,PD,NE,1001,5,PD,OR,
0542,5,CH,NE,1006,5,CH,OR,
0547,5,CH,NE,1011,5,CH),
OVERLAY=(101:C'CR'))
/* |
_________________ Kolusu
www.linkedin.com/in/kolusu |
|