TALLY
Can be used in FASTREXX procedures.
Accumulates the value of the specified input record field in a TALLY register and, at the end of the File Manager function, prints on SYSPRINT or FMNRSUM the TALLY register prefixed by string. The TALLY is maintained across members of a PDS.
- Returns
- A single blank.
- start
- Start, in bytes, position of the field to be tallied in the input record.
- length
- Length, in bytes, of the field to be tallied in the input record.
- type
- The data type of the field to be accumulated. The values that
can be specified are:
- B
- Signed binary. If you specify B for type, length must be 2, 4, or 8.
- P
- Packed decimal. If you specify P for type, length must be between 1 and 16.
- UB
- Unsigned binary. If you specify UB for type, length must be 2, 4, or 8.
- Z
- Zoned decimal. This is the default. If you specify Z for type, length must be between 1 and 32 or, if the field contains a separate sign character or leading blanks, between 1 and 33. TALLY ignores leading blanks for zoned decimal fields, allowing simple character numeric fields to be tallied. Records containing only blanks in the target field are ignored. If a separate sign is present, there must be no blanks between the sign and the zoned data.
- string
- A literal string that is prefixed to the accumulated TALLY total.
The field whose value is to be accumulated starts at position start in the input record, and is length bytes long. If the sum of start and length is more than one greater than LENGTH(INREC), the TALLY function returns a blank without changing the TALLY register.
You can code more than one TALLY function in your procedure. File Manager creates a separate TALLY register for each TALLY function with a unique combination of arguments. This means that you can accumulate a given field in more than one TALLY register by specifying a different value for string in each TALLY function.
Example
Accumulate hours recorded in personnel records depending on record type.
Select
When (FLD(1,1) == 'E') Then
TALLY(15,4,B,'Sum of employee hours')
When (FLD(1,1) == 'S') Then
TALLY(15,4,B,'Sum of supervisor hours')
Otherwise
TALLY(28,4,B,'Sum of manager hours')
End