Skip to content

Column-Counter Clause

COLUMN-COUNTER is a special register that, at any given instant, contains the value of the rightmost column number of the most recently processed report field.

column counter

Use of Column-Counter

  • COLUMN-COUNTER indicates the current horizontal position within a line. At each stage during the processing of a line, it contains the most recent rightmost colum number on which data was placed in the line. It may also be incremented by an "empty" (unprintable) entry containing only a COLUMN clause. Regardless of the number of reports and report lines it contains, each program has just one COLUMN-COUNTER.

  • Report writer uses COLUMN-COUNTER as a place-keeper and internal subscript while assembling variable-length or variable-position fields in a report line. For the sake of efficiency, it does not initialize or update COLUMN-COUNTER in a report line consisting of fixed-length, fixed-position fields, unless you explicitly refer to it in an item in the line.

  • You may use COLUMN-COUNTER in the condition of a PRESENT WHEN clause, or as the operand of a SOURCE clause, or as a parameter to a FUNCTION (FUNCTION clause). It cannot be used in your PROCEDURE DIVISION, because the generating of each line is an indivisible operation.

  • COLUMN-COUNTER may be used to simplify the conditions that would otherwise be required to string together a series of conditional fields:

    column counter conditional fields

  • If your current group is a REPEATED group (see REPEATED clause), or if you use the SET COLUMN statement of the Page Buffer feature (see Report Writer SET statements), you should bear in mind that COLUMN-COUNTER is relative to the left-hand boundary of the group. So it does not include the extra left-hand margin used to offset your REPEATED groups or the extra margin you create with SET COLUMN.

  • COLUMN-COUNTER should not be used in a condition where the field is to be totalled using the SUM clause, because COLUMN-COUNTER is not updated when totalling is performed at the start of processing for the group.

Compatibility

COLUMN-COUNTER is unique to new Report Writer.

Back to top