How to get the Matching and Non-matching records f

2019-08-05 01:02发布

I have a requirement like below.

-> I have 2 input files FILE1 and FILE2.

-> Write the matching records into a FILE3.

-> Write the Non matching records from FILE1 into FILE4.

-> Write the Non matching records from FILE2 into FILE5.

The key position in both the Input Files is (1,10).

Can anybody please let me know the SORTCARD, how Can I get this in single step in SyncSort??

Thanks in Advance, Rajasekhar Jannu.

标签: mainframe jcl
2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-08-05 01:22
enter code here
//JOIN EXEC PGM=SORT 
//SORTJNF1 DD * 
1234567890 FILEB 
1234678901 FILE1 
/* 
//SORTJNF2 DD * 
1234567890 FILEB 
1234789012 FILE2 
/* 
//JNF1CNTL DD DUMMY             <=== not necessary(informatory)
//JNF2CNTL DD DUMMY             <=== not necessary(informatory)
//BOTH     DD DSN=<FILENAME>
//FILE1 DD DSN=<file name> 
//FILE2 DD DSN=<file name>
//SYSOUT DD SYSOUT=* 
//SYSPRINT DD SYSOUT=* 
//SORTOUT DD SYSOUT=*           <=== we can see the JOIN output here(explanatory)
//SYSIN DD * 
 JOINKEYS FILE=F1,FIELDS=(1,10,A) 
 JOINKEYS FILE=F2,FIELDS=(1,10,A) 
 JOIN UNPAIRED,F1,F2 
 REFORMAT FIELDS=(F1:1,16,F2:1,16),FILL=C'@' 
 OPTION COPY 
 OUTFIL FNAMES=BOTH, 
 INCLUDE=(01,01,CH,NE,C'@',AND,17,01,CH,NE,C'@'),BUILD=(1,16)
 OUTFIL FNAMES=FILE1,
 INCLUDE=(01,01,CH,NE,C'@',AND,17,01,CH,EQ,C'@'),BUILD=(1,16)
 OUTFIL FNAMES=FILE2,
 INCLUDE=(01,01,CH,EQ,C'@',AND,17,01,CH,NE,C'@'),BUILD=(17,16)
 /*  

 //***** this REFORMAT output would be something like
 1234567890 FILEB1234567890 FILEB 
 1234678901 FILE1@@@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@@1234789012 FILE2  
 //*********************************

FILL=C'@' pads the charecter '@' to the record produced by JOIN operation, so that this padded charecter can be used later at the time of Filter using INCLUDE

查看更多
爷的心禁止访问
3楼-- · 2019-08-05 01:37
JOINKEYS FILE=F1,FIELDS=(01,10,A)
JOINKEYS FILE=F2,FIELDS=(01,10,A)
UNPAIRED F1,F2   <== This results in cartesian product
REFORM FIELDS=(F1:01,10,F2:01,10),FILL=C'$'
SORT FIELDS=(01,10,CH,A)
OUTFIL FNAMES=03,
INCLUDE=(01,01,CH,NE,C'$',AND,11,01,CH,NE,C'$')  <== Matched Records
OUTFIL FNAMES=04,
INCLUDE=(01,01,CH,NE,C'$',AND,11,01,CH,EQ,C'$')  <== Non-Matched Records from File1
OUTFIL FNAMES=03,
INCLUDE=(01,01,CH,EQ,C'$',AND,11,01,CH,NE,C'$')  <== Non-Matched Records from File2

Also, note that only 10bytes have been considered from both the files as you didnt mention the lengths of each file.

Also suggest you to search known mainframe forums and post it here if you dont get the working solution. Hope this helps

Refer this: Joinkeys Guide

查看更多
登录 后发表回答