Page 1 of 1

Count & Compare record totals in two files - Set RC

PostPosted: Thu May 05, 2011 2:35 pm
by Kevin Jenkins
I have two sequential input files (IN01 & IN02) which are both RECFM=FB, LRECL=80.

I want to test if the count of records in file IN02 is greater than that in file IN01. If this is true I want to set RC=0, otherwise I want to set RC=4. Please can you suggest a DFSORT solution to this.

Thanks & Regards, Kevin

Re: Count & Compare record totals - Set RC

PostPosted: Thu May 05, 2011 2:54 pm
by Kevin Jenkins
Apologies, forgot to include - maintenance level is ICE201I G RECORD TYPE ... November, 2009 DFSORT

Re: Count & Compare record totals in two files - Set RC

PostPosted: Thu May 05, 2011 9:14 pm
by skolusu
kevin Jenkins,

Use the following DFSORT JCL which will give you the desired results. The RC is set to 0 if the file 2 has atleast 1 record more than file 1. An RC of 4 is set when file 2 has equal or less number of records in file 1

//STEP0100 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//INA      DD *                                     
F1-R1                                               
F1-R2                                               
F1-R3                                               
//INB      DD *                                     
F2-R1                                               
F2-R2                                               
F2-R3                                               
F2-R4                                               
F2-R5                                               
F2-R6                                               
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                     
  OPTION COPY                                       
  JOINKEYS F1=INA,FIELDS=(1,1,A)                     
  JOINKEYS F2=INB,FIELDS=(1,1,A)                     
  REFORMAT FIELDS=(F1:2,8,F2:2,8)                   
  OUTFIL NULLOFL=RC4,INCLUDE=(9,8,ZD,GT,1,8,ZD)     
//*                                                 
//JNF1CNTL DD *                                     
  INREC BUILD=(X,7C'0',C'1')                         
  SUM FIELDS=(2,8,ZD)                               
//*                                                 
//JNF2CNTL DD *                                     
  INREC BUILD=(X,7C'0',C'1')                         
  SUM FIELDS=(2,8,ZD)                               
//*

Re: Count & Compare record totals in two files - Set RC

PostPosted: Fri May 06, 2011 1:15 am
by Kevin Jenkins
Many thanks Skolusu. I've tested the solution and it delivers exactly what I was hoping for.

Regards, Kevin