The MOVE statement transfers data from one area of storage to one or more other areas.
CORR is an abbreviation for, and is equivalent to, CORRESPONDING.
- identifier-1 , literal-1
- The sending area.
- The receiving areas. identifier-2 must not reference an intrinsic function.
When format 1 is specified:
- All identifiers can reference alphanumeric group items, national group items, UTF-8 group items, or elementary items.
- When one of identifier-1 or identifier-2 references a national group item and the other operand references an alphanumeric group item, the national group is processed as a group item; in all other cases, the national group item is processed as an elementary data item of category national.
- When one of identifier-1 or identifier-2 references a UTF-8 group item and the other operand references an alphanumeric group item, the UTF-8 group is processed as a group item; in all other cases, the UTF-8 group item is processed as an elementary data item of category UTF-8.
- The data in the sending area is moved into the data item referenced by each identifier-2 in the order in which the identifier-2 data items are specified in the MOVE statement. See Elementary moves and Group moves below.
When format 2 is specified:
- Both identifiers must be group items.
- A national group item is processed as a group item (and not as an elementary data item of category national).
- A UTF-8 group item is processed as a group item (and not as an elementary data item of category UTF-8).
- Selected items in identifier-1 are moved to identifier-2 according to the rules for the CORRESPONDING phrase. The results are the same as if each pair of CORRESPONDING identifiers were referenced in a separate MOVE statement.
Data items described with the following types of usage cannot be specified in a MOVE statement:
- OBJECT REFERENCE
A data item defined with a usage of INDEX, POINTER, FUNCTION-POINTER, PROCEDURE-POINTER, or OBJECT REFERENCE can be part of an alphanumeric group item that is referenced in a MOVE CORRESPONDING statement; however, no movement of data from those data items takes place.
The evaluation of the length of the sending or receiving area can be affected by the DEPENDING ON phrase of the OCCURS clause (see OCCURS clause).
If the sending field (identifier-1) is reference-modified or subscripted, or is an alphanumeric or national function-identifier, the reference-modifier, subscript, or function is evaluated only once, immediately before data is moved to the first of the receiving operands.
Any length evaluation, subscripting, or reference-modification associated with a receiving field (identifier-2) is evaluated immediately before the data is moved into that receiving field.
For example, the result of the statement:
MOVE A(B) TO B, C(B).
is equivalent to:
MOVE A(B) TO TEMP. MOVE TEMP TO B. MOVE TEMP TO C(B).
TEMP is defined as an intermediate
result item. The subscript
B has changed in value
between the time that the first move took place and the time that
the final move to
C(B) is executed.
For further information about intermediate results, see Appendix A. Intermediate results and arithmetic precision in the Enterprise COBOL Programming Guide.
After execution of a MOVE statement, the sending fields contain the same data as before execution.
Usage note: Overlapping operands in a MOVE statement can cause unpredictable results.