TALLY
Accumulates the value of the specified input record field in a TALLY register and, at the end of the Import utility, prints on SYSPRINT the TALLY register prefixed by the character string string. If the TALLY function is successful, it returns a value of 0. If it is unsuccessful, it raises the REXX syntax error condition.
The field whose value is to be accumulated starts at position start (in bytes) in the input record, and is length bytes long. If the sum of start and length is greater than LENGTH(INREC), the TALLY function returns a value of 0 without changing the TALLY register.
- B
- if the field is binary. If you specify B for type, length must be 2, 4, or 8. The field is assumed to be signed.
- P
- if the field is packed decimal. If you specify P for type, length must be between 1 and 16 bytes.
- Z
- if the field is zoned decimal. If you specify Z for type, length must be between 1 and 32 bytes or, if the field contains a separate sign character, between 1 and 33 bytes.
The default value for type is Z.
You can code more than one TALLY function in your procedure. FM/Db2 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
select;
when(fld(1,1) = 'E') then
rc = TALLY(15,4,B,'Sum of employee hours')
when(fld(1,1) = 'S') then
rc = TALLY(15,4,B,'Sum of supervisor hours')
otherwise
rc = TALLY(28,4,B,'Sum of manager hours')
end