Posts

Showing posts from October, 2012

Parse and separate strings in records of a flat file

Image
Lets say we have a file with records containing some strings which we care about. Lets assume all these strings of interest follow a pattern in the records such that they are followed by the word 'COPY' and then a space after it. The file would look something like: 12345COPY string1  111COPY string2 1234COPY string3 Now we want the output file to have all these "string*" values as the records of length 8 characters. For this we can use the Parse command of DFSORT in the following way. //SP02 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD DSN=DAIW.IMG.SRTPARSE.IN,DISP=SHR //SORTOUT DD DSN=DAIW.IMG.SRTPARSE.OUT, //             RECFM=FB, //             LRECL=8, //             DSORG=PS, //             AVGREC=U, //             SPACE=(TRK,(20,10),RLSE), //             DISP=(NEW,CATLG,DELETE),...

Using JOINKEYS of DFSORT for matching and merging datasets

Image
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.DATA...