Joined: 17 Oct 2004 Posts: 190 Location: hyderabad
the is a count function in DFSort
COUNT is an automatic DFSORT maintained counter of all records for this statement.
OUTFIL TRAILER1=(20:'NUMBER OF RECORDS ON FILE? ,COUNT),NODETAIL
In this example a count of the number of records on the input file is printed at the end of sorting. The NODETAIL specifies that no detail lines are to be printed. If this was not specified every record would be printed unformatted.
COUNT - prints a message containing the count of records in a data set. Can also be used to set RC=12 or RC=0 based on the count of records in a data set (that is, empty, not empty, higher, lower, equal or not equal).
Note that COUNT=(M11,LENGTH=8) gives us an 8-byte count with leading zeros. COUNT=(TO=ZD,LENGTH=8) would do that as well. We could use other edit masks or conversion formats to display the count in other ways, e.g. COUNT=(EDIT=(III,IIT)) or COUNT=(TO=FS,LENGTH=8).
We also use NODETAIL to suppress the detail records, and REMOVECC to suppress the ANSI carriage control character.
Alternatively, you can use the COUNT operator of DFSORT's ICETOOL to display the COUNT in a message in the TOOLMSG data set.