Page 2 of 2

Re: SORT utility to eliminate the duplicate records

PostPosted: Fri Oct 31, 2008 9:29 pm
by jaganmoni
Hi Frank,

I have two files (FILE A and FILE B). The file LRECL, RECFM and type for both files are 13, FB, CH. I want to Compare FILE A and FILE B. If the File A record is in FILE B I want to write it in FILE C. If the file FILE A record is not in FILE B I want to write it in file D.
Can you please help me on this...
The data in each file is like below:

Input Files:
FILE A:
00018-0004787
00018-0004808
00042-0000023
00042-0002140

FILE B:
00018-0004370
00018-0004565
00018-0004787
00026-0000580

Output Files:
FILE C:
00018-0004787

FILE D:
00018-0004808
00042-0000023
00042-0002140

Re: SORT utility to eliminate the duplicate records

PostPosted: Fri Oct 31, 2008 10:21 pm
by Frank Yaeger
Here's a DFSORT/ICETOOL job that will do what you asked for:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//FILEA DD DSN=...  input fileA (FB/13)
//FILEB DD DSN=...  input fileB (FB/13)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//FILEC DD DSN=...  output fileC (FB/13)
//FILED DD DSN=...  output fileD (FB/13)
//TOOLIN DD *
COPY FROM(FILEA) TO(T1) USING(CTL1)
COPY FROM(FILEB) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(FILEC) ON(1,13,CH) ALLDUPS DISCARD(FILED) -
  USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(14:C'1')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(14:C'2')
/*
/CTL3CNTL DD *
 OUTFIL FNAMES=FILEC,INCLUDE=(14,1,CH,EQ,C'1'),BUILD=(1,13)
 OUTFIL FNAMES=FILED,INCLUDE=(14,1,CH,EQ,C'1'),BUILD=(1,13)
/*