Previous Topic: ParametersNext Topic: ADDCNTL


Example 1

This keyword accumulates the four-byte packed field starting in position 10. The description field is used for the total line title.

READ,
  ACCUM(10,4,P,'POSITION 10')

A C C U M S U M M A R Y Description Total Records POSITION 10 -6 3

Example 2

This next example shows the previous example when invalid data is detected.

A C C U M S U M M A R Y Description Total Records Invalid Values POSITION 10 -4 2 1

Example 3

This example accumulates separately the two packed fields, Field-One and Field-Two. The description fields are used for the total line titles.

READ,
  LAYOUTFILE(LAYOUT),
  ACCUM(FIELD-ONE,'TOTAL FIRST-FIELD'),
  ACCUM(FIELD-TWO,'TOTAL-SECOND-FIELD')

A C C U M S U M M A R Y Description Total Records Total First-Field -6.9865 3 Total Second-Field 15 3

Example 4

The default TOTAL serves as the total line title when the description field is omitted. Since the data-type parameter is omitted, the data beginning at position for length of 5 is assumed to be valid packed numeric.

READ,
  ACCUM(76,5),
  ACCUM(81,5)

A C C U M S U M M A R Y Description Total Records TOTAL -6 3 TOTAL 15 3

Example 5

This example sets the number of decimal positions to the right of the decimal point for a binary halfword field.

READ,
  ACCUM(5,2,2,B,C'BINARY DECIMAL')

You could obain the same results by simply referencing the field-name that is described by the position, length, and decimal-positions parameters

READ,
  ACCUM(FIELD-ONE,C'BINARY DECIMAL')

A C C U M S U M M A R Y Description Total Records BINARY DECIMAL 1.31070 2

Example 6

The record is scanned for the value TOTALS. When it is found at record location 45, the numeric values at locations 52, 55, and 59 respectively are accumulated.

READ,
  IF(1,80,EQ,C'TOTALS'),
    ACCUM(+7,3,N,'CUSTOMER SALES'),
    ACCUM(+11,3,N,'CUSTOMER RETURNS'),
    ACCUM(+14,3,N,'CUSTOMER COMPLAINTS')