The MOVE statement transfers data, in accordance with the rules of editing, to one or more data areas.
General Formats for Format 1
General Formats for Format 2
Directives
- In addition to Compiler directives which provide flagging and modify the reserved word list, the following directives may
impact either the syntax or the semantics described in this section.
- BYTE-MODE-MOVE - impacts the behavior of MOVE statements in which the sending and receiving items share a part of their storage
(that is, overlapping moves).
- DBCS (DBSPACE) - impacts what characters are used for space-filling DBCS receiving items.
- DE-EDIT - controls whether the value of numeric-edited sending fields is determined by their PICTURE clause or not.
- TRUNC - determines whether truncation occurs based on the storage available or the PICTURE clause, when the sending item includes
a value larger than a binary receiving value's size.
Syntax Rules for All Formats
- Identifier-1 and literal represent the sending area; identifier-2 represents the receiving area.
- An index-name or an index data item may not be specified as an operand of a MOVE statement.
- If the sending or receiving item is a pointer data item or an ADDRESS OF operand, then the other operands of the MOVE statement
must also be pointer data items or ADDRESS OF operands or, in the case of the sending item, NULL.
- If the sending or receiving item is an object reference, a program-pointer, an entry-pointer, a monitor-pointer, a mutex-pointer,
a semaphore-pointer or a thread-pointer, then all other operands of the MOVE statement must be of the same type or, in the
case of the sending item, NULL.
- If either the sending or receiving item is a DBCS (USAGE DISPLAY-1) item, then both must be DBCS items. The figurative constant
SPACE can be the DBCS sending item.
Syntax Rules for Format 1
- When Format 1 is specified, all identifiers can reference alphanumeric group items, national group items
, UTF-8 group items
, or elementary items. The data in the sending area is moved into the data item referenced by each identifier-2 in the order
in which it is specified.
- Identifier-1 may be a numeric function-identifier.
- If identifier-1 is a data item described with USAGE BINARY-CHAR, USAGE BINARY-SHORT, USAGE BINARY-LONG or USAGE BINARY-DOUBLE,
identifier-2 must be a numeric or numeric-edited item; otherwise, see Table 1, MOVE Statement Data Categories, below which
specifies the validity of the move.
Syntax Rules for Format 2
- CORR is an abbreviation for CORRESPONDING.
- When the CORRESPONDING phrase is used, all identifiers must be group items.
- The following items can be part of a group that is referenced in a MOVE CORRESPONDING statement; however, no movement of this
item takes place:
- POINTER, PROCEDURE-POINTER
- POINTER-32
- OBJECT-REFERENCE, PROGRAM-POINTER
- EVENT-POINTER, MONITOR-POINTER, MUTEX-POINTER, SEMAPHORE-POINTER, THREAD-POINTER.
General Rules for All Formats
- If identifier-1 is a numeric function-identifier, then identifier-2 must be either a numeric or numeric-edited item.
- The data designated by the literal or identifier-1 is moved to the data item referenced by each identifier-2, in the order
in which it is specified. The rules referring to identifier-2 also apply to the other receiving areas. Any subscripting or
indexing associated with identifier-2, is evaluated immediately before the data is moved to the respective data item.
If identifier-1 is reference modified, subscripted, or is a function-identifier, the reference modifier, subscript, or function-identifier
is evaluated only once, immediately before data is moved to the first of the receiving operands.
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)
where temp is an intermediate result item provided by your COBOL system.
- Any MOVE in which the sending and receiving items are both elementary items is an elementary move. Every elementary item belongs
to one of the following categories: numeric, alphabetic, alphanumeric, numeric-edited, alphanumeric-edited
national, national-edited, boolean
, UTF-8,
or floating-point.
These categories are described in the PICTURE clause. Numeric literals belong to the category numeric, and nonnumeric literals
belong to the category alphanumeric. The figurative constant ZERO belongs to the category numeric when moved to a numeric
or numeric-edited item. The figurative constant ZERO belongs to the category alphanumeric in all other cases. The figurative
constant SPACE belongs to the category alphabetic. All other figurative constants belong to the category alphanumeric.
The following rules apply to an elementary move between these categories:
- The figurative constant SPACE, or an alphanumeric-edited, or alphabetic data item must not be moved to a numeric or numeric-edited
data item.
- A numeric-edited data item must not be moved to a numeric or numeric-edited data item
, or boolean
.
This restriction is removed.
- A numeric literal, the figurative constant ZERO, a numeric data item or a numeric-edited data item
, or a boolean data item
must not be moved to an alphabetic data item.
- A non-integer numeric literal or a non-integer numeric data item must not be moved to an alphanumeric or alphanumeric-edited
data item
, or boolean data item
.
-
If identifier-2 is a boolean data item, it can only receive figurative constants whose associated characters are boolean characters.
-
An alphabetic, alphanumeric-edited, numeric, or national data item must not be moved to a boolean data item.
-
A boolean data item must not be moved to a national data item.
- When moving non-UTF-8 items to a UTF-8 item, the sending characters are converted to UTF-8. They are converted as if moved
to temporary data items of category UTF-8 and with sufficient length to not cause any padding or truncation. The resulting
category UTF-8 item is treated as the sending data item.
- If sending an item of class UTF-8 to another item of class UTF-8, no conversion is performed during the move.
- Due to any alignment and any padding or truncation that may occur during a UTF-8 move, the programmer is responsible for ensuring
that multiple encoding units that together form a graphic character are not split by truncation.
- If the receiving item is a dynamic-length elementary item, its length is set to the minimum of the length of the sender or
the explicit or implied value of the LIMIT phrase. If the sending item's length is greater than that of the receiving item,
truncation of the excess characters on the right occurs.
- All other elementary moves are legal and are performed according to the rules given in General Rule 5.
- Any necessary conversion of data from one form of internal representation to another takes place during legal elementary moves,
along with any editing specified for
, or de-editing implied by,
the receiving data item:
- When an alphanumeric-edited or alphanumeric item is a receiving item, alignment and any necessary space-filling takes place
as defined in the topic
Standard Alignment Rules in the chapter
Concepts of the COBOL Language. If the size of the sending item is greater than the size of the receiving item, the excess characters are truncated on the
right after the receiving item is filled. If the sending item is described as being signed numeric, the operational sign is
not moved; if the operational sign occupies a separate character position (see the topic
The SIGN Clause), that character is not moved and the size of the sending item is considered to be one less than its actual size (in terms
of standard data format characters).
- When a numeric or numeric-edited item is the receiving item, alignment by decimal point and any necessary zero-filling takes
place as defined in the section
Standard Alignment Rules in the chapter
Concepts of the COBOL Language, except where zeros are replaced because of editing requirements.
When the sending operand is numeric-edited, de-editing is implied to establish the operand's unedited numeric value, which
can be signed; then the unedited numeric value is moved to the receiving field. The effect of de-editing depends on the setting
of the DE-EDIT Compiler directive
When a signed numeric item is the receiving item, the sign of the sending item is placed in the receiving item. (See the topic
The SIGN Clause.) Conversion of the representation of the sign takes place as necessary. If the sending item is unsigned, a positive sign
is generated for the receiving item.
When an unsigned numeric item is the receiving item, the absolute value of the sending item is moved and no operational sign
is generated for the receiving item.
When a data item described as alphanumeric is the sending item, data is moved as if the sending item were described as an
unsigned numeric integer.
When the receiving item is numeric or numeric-edited and the sending item is defined as alphanumeric, if the content of the
sending item is not an integer, the results of the move are undefined. If the alphanumeric sending item is a literal whose
contents do not represent an integer, an error is reported, and zero moved to the target. (See the topic
Incompatible Data in the chapter
Procedure Division.)
When the numeric data item is the sending item the action of the move is such that a reverse of the move would cause the same
value to appear in the numeric-edited field (except for truncation). If the data item contains data which does not conform
to the edited picture, zero is moved to the target.
- When a receiving field is described as alphabetic, justification and any necessary space-filling takes place as defined in
the topic
Standard Alignment Rules in the chapter
Concepts of the COBOL Language. If the size of the sending item is greater than the size of the receiving item, the excess characters are truncated on the
right after the receiving item is filled.
- When the receiving field is floating-point, the sending item is converted first to internal floating-point and then moved.
When data is moved to or from an external floating-point item, the data is converted first to or from its equivalent internal
floating-point value.
-
When the receiving field is non-NCHAR DBCS, the sending item must be DBCS or national; no conversion takes place. If the sending
and receiving items are not the same size the data item is either truncated or padded with DBCS spaces on the right.
- Any move that is not an elementary move is treated exactly as if it were an alphanumeric to alphanumeric elementary move,
except that no conversion of data from one form of internal representation to another takes place. In such a move, the receiving
area is filled without consideration for the individual elementary or group items contained in either the sending or receiving
area, except as noted in the General Rules of the OCCURS clause.
- Table 1 below summarizes the legality of the various types of MOVE statements. The general rule reference indicates the rule
that prohibits the move or the behavior of a legal move.
- When the receiving field is boolean, the boolean value of the sending item is moved, with conversion of data representation
if necessary, and any necessary alignment and zero filling as defined in the topic
Standard Alignment Rules in the sectionConcepts of the COBOL Language. If the sending field is not boolean, it is treated as if it were a boolean data item with the same usage and number of character
positions as the sending field. If the content of the sending field would result in a false value in a boolean class condition,
an error is reported (see the topic
Incompatible Data in the section
Procedure Division.)
- The following table shows a summary of permissible moves, with reference to more detailed explanations within this topic:
Category of Sending Item
|
Category of Receiving Data Items (the relevant rule number is quoted in these columns)
|
Alphabetic
|
Alphanumeric-Edited/ Alpha-numeric
|
Numeric Integer/Non-Integer
|
Numeric-Edited External/Internal Floating Point
|
National
|
Non-NCHAR DBCS
|
NCHAR DBCS
|
Boolean
|
UTF-8
|
Alphabetic
|
Yes/4c
|
Yes/4a
|
No/3a
|
No/3a
|
Yes
|
No/4e
|
Yes
|
No/3f
|
Yes
|
Alphanumeric
|
Yes/4c
|
Yes/4a
|
Yes/4b
|
Yes/4b
|
Yes
|
No/4e
|
Yes
|
Yes/3e
|
Yes
|
Alphanumeric-Edited
|
Yes/4c
|
Yes/4a
|
No/3a
|
No/3a
|
Yes
|
No/4e
|
Yes
|
No/3f
|
Yes
|
Numeric Integer
|
No/3c
|
Yes/4a
|
Yes/4b
|
Yes/4b
|
Yes
|
No/4e
|
Yes
|
No/3f
|
No
|
Numeric Non-Integer
|
No/3c
|
No/3c
|
Yes/4b
|
Yes/4b
|
No
|
No/4e
|
No
|
No/3f
|
No
|
Numeric-Edited
|
No/3c
|
Yes/4a
|
Yes/4b
|
Yes/4b
|
Yes
|
No/4e
|
Yes
|
No/3f
|
Yes
|
National
|
No
|
No
|
Yes
|
Yes
|
Yes
|
Yes
|
Yes
|
No
|
Yes
|
Non-NCHAR DBCS
|
No/4e
|
No/4e
|
No/4e
|
No/4e
|
Yes
|
Yes/4e
|
Yes
|
No/3f
|
No
|
NCHAR DBCS
|
Yes
|
Yes
|
No
|
No
|
Yes
|
Yes/4e
|
Yes
|
No
|
No
|
Boolean
|
No/3c
|
Yes/4a
|
No/3b
|
No/3b
|
No
|
No/3g
|
No
|
Yes/4f
|
No
|
UTF-8
|
No
|
No
|
No
|
No
|
Yes
|
No
|
No
|
No
|
Yes
|
Note: An error is reported if a non-integer alphanumeric literal sending item is used
For more information on NCHAR DBCS support, refer to
Micro Focus Extensions for Double-byte Character Set Support, and for more information on non-NCHAR DBCS support, refer to
Double-byte Character Set Support.
General Rules for Format 1
- When either identifier 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 either identifier 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.
- UTF-8 group items are processed as group items, and not as elementary data items of category UTF-8.