Reference modification defines a unique data item by specifying an identifier, a leftmost position and a length.
General Format
identifier-1 ( leftmost-position : [length] )
Syntax Rules
- Identifier-1 must reference a data item that is one of the following:
- An elementary item of class alphanumeric or national
- A numeric item of usage display
- A group item
Note: Identifier-1 must not be an individual boolean data item or a group item defined by the GROUP-USAGE BIT clause.
- Leftmost-position and length must be arithmetic expressions.
- Unless otherwise specified, reference modification is allowed anywhere an identifier referencing a data item of the class
alphanumeric or national is permitted.
- Identifier-1 must not include reference-modification.
- Identifier-1 must not be a dynamic-length group item.
- If identifier-1 is a function-identifier, it must reference an alphanumeric or national function.
General Rules
- Leftmost-position represents an alphanumeric position or national position when identifier-1 references an alphanumeric or
national data item, respectively.
- Each position of the data item referenced identifier-1 is assigned an ordinal number incrementing by one from the leftmost
position to the rightmost position. The leftmost position is assigned the ordinal number one. If the data description entry
for identifier-1 contains a SIGN IS SEPARATE clause, the sign position is assigned an ordinal number within that data item.
- If the data item referenced by identifier-1 is explicitly or implicitly described as usage DISPLAY and the category is numeric,
external floating-point,
numeric edited, alphabetic, or alphanumeric edited, it is operated upon for purposes of reference modification as if it were
redefined as an alphanumeric data item of the same size as the data item referenced by identiifer-1.
- Reference modification for an operand is evaluated as follows:
- If subscripting is specified for the operand, the reference modification is evaluated immediately after evaluation of the
subscripts. If an ALL subscript is specified for an operand, the reference-modifier is applied to each of the implicitly specified
elements of the table.
- If subscripting is not specified for the operand, the reference modification is evaluated at the time subscripting would have
been evaluated if subscripts had been specified.
- If reference modification is specified in a function reference, the reference modification is evaluated immediately after
evaluation of the function.
- If reference modification is specified in an object property reference, the reference modification is evaluated immediately
after evaluation of the object property.
- Reference modification creates a unique data item that is a subset of the data item referenced by identifier-1. This unique
data item is defined as follows:
- The evaluation of leftmost-position specifies the ordinal position of the leftmost character of the unique data item in relation
to the leftmost character of the data item referenced by identifier-1. Evaluation of leftmost-position must result in a positive
nonzero integer less than or equal to the number of positions in the data item referenced by identifier-1.
The results are rounded if the expression is in floating-point, and truncated if the expression is in fixed-point.
- The evaluation of length specifies the size in characters of the data item to be used in the operation. The evaluation of
length must result in a positive nonzero integer. The sum of leftmost-position and length minus the value one, must be less
than, or equal to, the number of characters in the data item referenced by identifier-1. If length is not specified, the unique
data item extends from and includes the character identified by leftmost-position, up to and including the rightmost character
of the data item referenced by identifier-1.
The results are rounded if the expression is in floating-point, and truncated if the expression is in fixed-point.
Note: There is no check that the evaluation of leftmost-position and length produce valid values. If these evaluations do not conform
to the restrictions stated in this rule, the result is undefined and other data items may be corrupted.
- The unique data item is considered an elementary data item without the JUSTIFIED clause. The unique data item has the same
class, category and usage as that defined for the data item referenced by identifier-1, except that:
- If the OSVS Compiler directive is set, reference modification cannot be used in conditional expressions (see the topic
Conditional Expressions).
- If identifier-1 is a a dynamic-length elementary item, it is handled as if it were a fixed-length item whose length is equivalent
to the current dynamic-length elementary item. When used as a reference modified receiving item in a PROCEDURE DIVISION statement,
the current length of the dynamic-length elementary item is not modified.