Assignment STATEMENTS

PURPOSE:  The value modification statements provide a variety of ways to easily modify existing field values or to set initial values to fields.

SYNTAX

ASSIGNMENT statement

exp TO \\fields\\ [HUSH] [IF; UNLESS clause] [iterate clause]

INCR \\fields [BY ae]\\ [HUSH] [IF; UNLESS clause] [iterate clause]

DECR \\fields [BY ae]\\ [HUSH] [IF; UNLESS clause] [iterate clause]

ADD ae TO field [HUSH] [IF; UNLESS clause] [iterate clause]

SUB ae FROM field [HUSH] [IF; UNLESS clause] [iterate clause]

exp

can be a constant, literal, variable name, date expression, string expression, arithmetic expression, function, or field.  In each case, the data type of values must be appropriate to the destination field. Its length should not exceed that of the destination field.  If a string value is too long, it is truncated.

fields

can be any of the fields available for change in the current section.  Declared fields, Global Storage (GS) fields, and certain system fields are always available for value modification.  Master, transaction, and auxiliary Data Set (DS) fields can be changed as permitted by the Process Module (PM) section.

ae

is an arithmetic expression that can contain literals, constants, fields, and functions if they evaluate to numeric or integer values.  They can be used individually or in combination with any of the arithmetic operators.

INCR \\fields [BY ae]\\

increases the value of the field(s) by the value ae.  If BY ae is not stated, the value of ae is assumed to be 1.

DECR \\fields [BY ae]\\

decreases the value of the field(s) by the value of ae.  If BY ae is not stated, the value of ae is assumed to be 1.

ADD ae TO field

adds the value of ae to the field value.

SUB ae FROM field

subtracts the value of ae from the field value.

Example

0 TO UNITS (II) FOR II = 1 TO 100
SUB 50 FROM AMOUNT:D IF OTY:D > 50
"FL1203" TO TITLE_CODE ! Set field value
INCR CTR:D or
ADD 1 TO CTR:D
0 TO CTR:D ! Reset counter value
DECR CTR:D or
SUB 1 FROM CTR:D
0 TO ARY (II, JJ, KK) FOR II=1 TO 10, JJ=1 TO5, KK=1 TO 50

NOTES:  Value modification statements are valid in any section except CONTROL and DECLARE.