Using JOINKEYS of DFSORT for matching and merging datasets

Saturday, October 20, 20120 comments

Joinkeys applications of DFSORT is a very useful application to match and merge files. The below example joins two input datasets based on a key. The two datasets may have the keys in different data formats, so we can use various data conversion techniques of SORT using INREC in the JNF*CNTL files. Matched records, Records which are only present in dataset 1 and records which are present only in dataset 2 can be segregated using this technique.


//JS010 EXEC PGM=SORT

//SYSOUT DD SYSOUT=*

//IN1 DD DSN=ATOM.INPUT.DATASET1,DISP=SHR

//IN2 DD DSN=ATOM.INPUT.DATASET2,DISP=SHR

//SYMNAMES DD *
   IN1_CUST_ZD,3,6,ZD
   
   IN2_CUST_PD,6,4,PD
   
   IN2_CUST_ZD,=,6,ZD

//JNF1CNTL DD *
   INREC OVERLAY=(IN1_CUST_ZD:IN1_CUST_ZD,TO=ZDF,LENGTH=6)

//JNF2CNTL DD *
   INREC OVERLAY=(IN2_CUST_PD:IN2_CUST_PD,TO=ZDF,LENGTH=6)

//OUT1   DD SYSOUT=*

//OUT2   DD SYSOUT=*

//OUT12  DD DSN=ATOM.OUTPUT.DATASET.MATCHED,

//             RECFM=FB,

//             LRECL=13,

//             DSORG=PS,

//             AVGREC=U,

//             SPACE=(TRK,(800,100),RLSE),

//             DISP=(NEW,CATLG,KEEP),

//             UNIT=SYSDA

//SYSIN  DD *
   JOINKEYS F1=IN1,FIELDS=(IN1_CUST_ZD,A)

   JOINKEYS F2=IN2,FIELDS=(IN2_CUST_ZD,A)

   JOIN UNPAIRED,F1,F2

   REFORMAT FIELDS=(F1:1,8,F2:1,256,?)

   OPTION COPY

   OUTFIL FNAMES=OUT12,INCLUDE=(265,1,CH,EQ,C'B'),

   BUILD=(1:1,8,9:21,3,PD,TO=ZDF,LENGTH=5)

   OUTFIL FNAMES=OUT1,INCLUDE=(265,1,CH,EQ,C'1'),
 
   BUILD=(1,8)

   OUTFIL FNAMES=OUT2,INCLUDE=(265,1,CH,EQ,C'2'),

   BUILD=(9,256)
/*
Share this article :

Post a Comment

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Atom's Arena - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger