I have a header record and N number of detailed records and finally a trailer record in my input file. I have to extract detailed records based on some condition and write it to the output file.Trailer record in the output file should contain the COUNT of all records that satisfied the condition (i.e # of detailed recs in o/p file).
Please help me on how to find the detailed record count.
Checked in few manuals but was not able to find this.Actually summary results in spool has the information i am looking for stored in SELTOT.However, i was not able to refer to that field inside the selcopy pgm.
OPTION WORKLEN=204 * Allocate user work area buffer.
POS COUNT = X'0000,000C' * Initialise the packed decimal count field.
READ INDD INTO INREC * Read next input record.
IF EOF INDD * End of input file reached ?
THEN POS TRAILREC="Number of records selected for output: xx,xxx"
THEN CVPC 4 AT COUNT TO TRAILREC+39 FMT=ZZ,ZZ9
THEN WRITE OUTDD FROM TRAILREC, TRAILREC+44
THEN GOTO EOJ * End-of-job.
IF.... * Test for output record criteria.
THEN WRITE OUTDD FROM INREC
THEN ADD 1 TO 4 AT COUNT * Increment the output record count.
* Processing loops back to the start of the control statements.
* Processing stops when end of prime input or GOTO EOJ is encountered.