Page 1 of 1

Count number of records of several files

PostPosted: Sun Apr 27, 2014 3:35 pm
by LACPTN
Hi all,

I want to count the number of records of several files and generate a file with the output. For example:
File 1:
A
B
File 2:
C
D
E
Output:
File1: 2
File2: 3

I'm doing this:
//SORT1 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=F1,DISP=SHR
//SORTOUT  DD DSN=FOUTPUT,
//            DISP=(,CATLG,DELETE),
//            DCB=(RECFM=FB,LRECL=33,BLKSIZE=0,DSORG=PS),
//            SPACE=(CYL,(10,10),RLSE),UNIT=SYSALLDA
//SYSIN DD *
  SORT FIELDS=COPY
  OUTFIL REMOVECC,NODETAIL,
  TRAILER1=('F1:',COUNT=(M11,LENGTH=8))
/*

//SORT2 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=F2,DISP=SHR
//SORTOUT  DD DSN=FOUTPUT,
//            DISP=(MOD,CATLG,DELETE),
//            DCB=(RECFM=FB,LRECL=33,BLKSIZE=0,DSORG=PS),
//            SPACE=(CYL,(10,10),RLSE),UNIT=SYSALLDA
//SYSIN DD *
  SORT FIELDS=COPY
  OUTFIL REMOVECC,NODETAIL,
  TRAILER1=('F2:',COUNT=(M11,LENGTH=8))
/*


That is working fine if the files have the same length (33 in this case). But I get the next error when F1 has a length of 33 and F2 has 32:
32 BYTE FIXED RECORD LENGTH IS NOT EQUAL TO 33 BYTE LRECL FOR SORTOUT


I also tried deleting "LRECL=33" but the problem is the same. I want to count the number of several records with different lengths and without set the length.

What can I do?

Thanks!

Re: Count number of records of several files

PostPosted: Sun Apr 27, 2014 5:32 pm
by NicC
create individual output files for each file and, once all have been created, concatenate them into one.