Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Reference modification

Function

Reference modification defines a data item through specification of the position of the leftmost character and the length of the data item.

Format


{identifier-1 | FUNCTION function-name-1 [({argument-1}... )] } (leftmost-char-position: [length])


identifier-1 and FUNCTION function-name-1 are not part of the reference-modifier. They are included here for the sake of clarity.

Syntax rules

  1. identifier-1 must be one of the following data items:

    • an elementary data item of the category alphanumeric or an alphanumeric group item.

    • an alphabetic data item.

    • a numeric or alphanumeric data item or a numeric data item with the USAGE DISPLAY phrase; in no cases may the data item be subordinate to a strongly typed group item.

    • a group data item which is not strongly typed.

    • a national data item.

    • a numeric edited or alphanumeric edited data item or a numeric data item with the USAGE DISPLAY phrase; in no cases may the data item be subordinate to a strongly typed group item.

  2. leftmost-character-position and length must be arithmetic expressions.

  3. Unless otherwise specified, reference modification may be used wherever an data item identifier of the class alphanumeric or national is permitted.

  4. identifier-1 must not be reference modificated.

  5. The function referenced by function-name-1 and its arguments (if any) must be an alphanumeric or national function.

  6. identifier-1 may not refer to a group data item that contains data items of the class “object” or “pointer”.

General rules

  1. Each character of identifier-1 or function-name-1 is assigned an ordinal number that is incremented stepwise by one from the leftmost position to the rightmost position. The number one is assigned to the leftmost position. If the data description entry for data-name-1 contains a SIGN IS SEPARATE clause, an ordinal number is likewise assigned to the sign position in this data item.

  2. If identifier-1 is described as numeric, numeric edited, alphanumeric or alphanumeric edited, it is operated upon for the purposes of reference modification as if it were redefined as an alphanumeric data item of the same size.

  3. If identifier-1 is subscripted and ALL is specified for a subscript, the reference-modifier refers to each of the implicitly referenced table elements.

  4. Reference modification creates a unique data item that forms a subset of the data item referenced by identifier-1 or function-name-1. This unique data item is defined as follows:

    • leftmost-character-position specifies the character position of identifier-1 at which the subfield is to begin.
      leftmost-character-position must give a positive nonzero integer value that is less than or equal to the number of character positions of identifier-1 or function-name-1 and its arguments (if any).

    • length denotes the length of the unique data item. length must give a positive nonzero integer value.

    • The sum of leftmost-character-position and length minus 1 must not exceed the number of characters of the data item referenced by identifier-1 or function-name-1. If "length" is not specified, the unique data item extends from the position denoted by leftmost-character-position to the last character (inclusive) of the data item referenced by identifier-1 or function-name-1.

    Note:
    In the case of national data it must be ensured that surrogate pairs are not separated by reference modification.

  5. The unique data item is considered to be an elementary item without a JUSTIFIED clause. The generated subfield has the same class and category as identifier-1 or as function-name-1 except that the categories numeric, numeric-edited and alphanumeric-edited are regarded as the class and category alphanumeric and USAGE DISPLAY is assumed for an alphanumeric group.

Example 2-12

A data item CARREG contains a 10-character car registration, the last 6 characters of which are to be transferred to a subitem SHORTREG:

Program extract:

...
01  CARREG     PIC X(10).
01  SHORTREG   PIC X(6).
...
    MOVE CARREG (5:6) TO SHORTREG.
...

The "5" within the parentheses specifies that the MOVE operation is to take effect starting at the fifth character; the colon is the required separator; the "6" specifies that six characters are to be transferred to the item SHORTREG.