Reference Modification in COBOL COBOL

Reference modification permits reference to a subfield of a data item. It may be used anywhere an identifier referencing an alphanumeric data item is allowed, unless explicitly disallowed by the rules for a specific statement.

data-name-1 ( leftmost-character-position-1 : [ length-1 ] )

data-name-1 must refer to a data item whose usage is DISPLAY (called “the operand” in this discussion).It may be qualified, subscripted or both.

leftmost-character-position-1 and length-1 are both arithmetic expressions as defined in the discussion beginning. The value of leftmost-character-position-1 specifies the leftmost character position of the subfield within the operand. The value of length-1 specifies the character length of the subfield. The subfield selected in this way is treated as an elementary data item without the JUSTIFIED clause. It has the same class and category as the operand, except that the categories numeric, numeric edited and alphanumeric edited are treated as class and category alphanumeric.

If the operand is described as numeric, numeric edited, alphabetic or alphanumeric edited, it is operated on for purposes of reference modification as if it were redefined as an alphanumeric data item of the same size as the operand.

Each character position of the operand is assigned an ordinal number starting with one at the leftmost character position and incrementing by one for each subsequent character position up to and including the rightmost character position. If the data description for the operand contains or is subject to a SIGN IS SEPARATE clause, the sign position is assigned an ordinal number in the same way as for the digit positions of the data item.

The value of leftmost-character-position-1 specifies the ordinal position of the leftmost character of the subfield with respect to the leftmost position of the operand. The evaluation must result in a positive integer not greater than the number of characters in the operand.

When length-1 is omitted, the subfield extends from the position specified by leftmost-character-position-1 up to and including the rightmost character position of the operand.

When length-1 is present, its value specifies the length in characters of the subfield. The evaluation must result in a positive integer. The sum of the values of the two expressions minus 1 must not be greater than the number of characters in the operand.

If subscripting is specified for the operand, the reference modification expressions are evaluated immediately after evaluation of the subscripts. If subscripting is not specified for the operand, the reference modification expressions are evaluated at the time subscripts would have been evaluated had they been specified.

When an identifier that refers to a level-number 01 or 77 Linkage Section data item formal argument is reference modified, the data item is resolved according to its description in the calling program. This is an exception to the rule that formal arguments are resolved according to their description in the Linkage Section of the called program. How the data item is resolved mainly affects the length of the data item as seen in the called program. See the “ Linkage Section ” topic, for additional information on this special case of resolving Linkage Section record-names.


Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

COBOL Topics