Previous Topic: Work Fields

Next Topic: Work Fields and the DEFINE(K) Statement


Work Fields and the DEFINE Statement

The DEFINE statement can be used to create work fields and initialize them with a numeric or character value.

FORMAT:   DEFINE fieldname EQ nnn
DEFINE fieldname EQ 'character string'

Unless otherwise indicated, the field is always reset to the initially assigned value whenever a new input record is processed. CA JARS Wizard also performs automatic accumulation for the field throughout the run and displays the work field's total on total lines.

Work fields created with the DEFINE statement cannot be used in preSORT statements, nor in the SORT or BREAK statements.

The following default formats and lengths are used:

Constant

Format

Length

Numeric

Packed

4 bytes

Literal

Character

4 bytes or as required by the literal

If the numeric value assigned is scaled, then the field is given a scaling characteristic.

If you do not like the above defaults, then you can specify explicitly the format, length, and scaling characteristics for the work field. For example:

DEFINE

Format

Length

Scaling

RATE EQ .75

PACKED

4 bytes

2 decimal places

FACTOR EQ 150

PACKED

4 bytes

 

NAME EQ 'TOTAL JOBS'

CHARACTER

10 bytes

 

CODE(H)(1) EQ 'FF'

HEXADECIMAL

1 byte