>> Wow, I did not want this to be so difficult...but given a choice, I would >> like the second approach
Billy, It isn't that difficult; we just need to adjust the way we are summing the results. Since you did not want the department row, we just need to switch to using SUM instead of Reporting features. Since we are using SUM, we need to handle the overflow of data, so when summing the 9 byte items, we will pad 3 zeroes and sum it as 12 byte so that we account for overflow of the summation. As for the header, generating a symbol by reading the 2nd record is the simplest and easiest way. //********************************************************** //* The filename is on the 2nd record of the file. use SORT* //* to read just that record and generate a symbol of the * //* filename. * //********************************************************** //GETFNAME EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD DISP=(OLD,PASS),DSN=&&FB //SORTOUT DD DSN=&&S,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE) //SYSIN DD * OPTION COPY,SKIPREC=1,STOPAFT=1 OUTREC BUILD=(02,44,JFY=(SHIFT=LEFT, LEAD=C'FILENAME,C''', TRAIL=C'''', LENGTH=80)) /* //********************************************************** //* Generate summary report of "D" records * //********************************************************** //GENREP EXEC PGM=SORT,COND=(0,LT) //SYSOUT DD SYSOUT=* //SYMNAMES DD DISP=(OLD,DELETE),DSN=&&S //SYMNOUT DD SYSOUT=* //SORTIN DD DISP=(OLD,PASS),DSN=&&FB //SORTOUT DD SYSOUT=* //SYSIN DD * INCLUDE COND=(019,03,FS,EQ,NUM,AND, # Field is numeric and 022,01,CH,EQ,C'D') # Type = D INREC BUILD=(001,03, # Department 3C'0', # pad 3 zeros 102,09,UFF,M11,LENGTH=9, # item qty C'00000001') # init counter SORT FIELDS=(01,03,CH,A) # Department SUM FIELDS=(04,12,ZD, # item 16,08,ZD) # count OUTFIL REMOVECC, BUILD=(C' DEPARTMENT ', 01,03, 16,08,ZD,M10,LENGTH=8, C' ARTICLES, TOTAL ITEMS: ', 04,12,ZD,M10,LENGTH=12), HEADER1=(FILENAME), TRAILER1=('*** TOTAL *** : ', TOT=(16,08,ZD,M10,LENGTH=8), ' ARTICLES, TOTAL ITEMS: ', TOT=(04,12,ZD,M10,LENGTH=12)) /* >> but for the sake of learning (if you don't mind), I would welcome the first >> option, also, to make my training more complete! Just run your existing control cards without any D records and see the output. (You will not have the filename as header, but you will have 1 row for department and total row) Thanks, Kolusu DFSORT Development IBM Corporation ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN