Previous Topic Next topic Print topic


The MOVE Statement

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

  1. 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

  1. Identifier-1 and literal represent the sending area; identifier-2 represents the receiving area.
  2. An index-name or an index data item may not be specified as an operand of a MOVE statement.
  3. MF 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.
  4. MF 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.
  5. VSC2MF 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

  1. OSVSVSC2MF When Format 1 is specified, all identifiers can be either group 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.
  2. MF Identifier-1 may be a numeric function-identifier.
  3. 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, Table 14-1, MOVE Statement Data Categories, specifies the validity of the move.

Syntax Rules for Format 2

  1. CORR is an abbreviation for CORRESPONDING.
  2. When the CORRESPONDING phrase is used, all identifiers must be group items.
  3. 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:
    • VSC2MF POINTER, PROCEDURE-POINTER
    • ISO2002MF  OBJECT-REFERENCE, PROGRAM-POINTER
    • MF  EVENT-POINTER, MONITOR-POINTER, MUTEX-POINTER, SEMAPHORE-POINTER, THREAD-POINTER.

General Rules for All Formats

  1. MF If identifier-1 is a numeric function-identifier, then identifier-2 must be either a numeric or numeric-edited item.
  2. 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.

    ANS85 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.

    ANS85 The result of the statement:

    ANS85 
     MOVE a(b) TO b, c(b)

    ANS85 is equivalent to:

    ANS85 
     MOVE a(b) TO temp MOVE temp TO b MOVE temp TO c(b)

    ANS85 where temp is an intermediate result item provided by your COBOL system.

  3. 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

    ISO2002MF national, national-edited, boolean

    OSVSVSC2MF 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:

    1. The figurative constant SPACE, or an alphanumeric-edited, or alphabetic data item must not be moved to a numeric or numeric-edited data item.
    2. A numeric-edited data item must not be moved to a numeric or numeric-edited data item

      ISO2002MF , or boolean

      .

      ANS85 This restriction is removed.

    3. A numeric literal, the figurative constant ZERO, a numeric data item or a numeric-edited data item

      ISO2002MF , or a boolean data item

      must not be moved to an alphabetic data item.
    4. A non-integer numeric literal or a non-integer numeric data item must not be moved to an alphanumeric or alphanumeric-edited data item

      ISO2002MF , or boolean data item

      .
    5. ISO2002MF If identifier-2 is a boolean data item, it can only receive figurative constants whose associated characters are boolean characters.
    6. ISO2002MF An alphabetic, alphanumeric-edited, numeric, or national data item must not be moved to a boolean data item.
    7. ISO2002MF A boolean data item must not be moved to a national data item.
    8. All other elementary moves are legal and are performed according to the rules given in General Rule 5.
  4. 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

    ANS85 , or de-editing implied by,

    the receiving data item:
    1. 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).
    2. 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.

      ANS85 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.)

      ANS85 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.

    3. 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.
    4. OSVSVSC2MF 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.
    5. VSC2MF When the receiving field is 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.

      ISO2002MF When the receiving field is national 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 national spaces on the right.

  5. 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.
  6. The table 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.
  7. ISO2002MF 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.)

General Rules for Format 2

  1. If the CORRESPONDING phrase is used, selected items in identifier-1 are moved to selected items in identifier-2, according to the rules given in The CORRESPONDING Phrase in the chapter Procedure Division. The results are the same as if you had referred to each pair of corresponding identifiers in separate MOVE statements.

    OSVSVSC2 The process is repeated for each destination group.

    Table 1. MOVE Statement Data Categories
    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 DBCS, national or national-edited Boolean
    Alphabetic Yes/4c Yes/4a No/3a No/3a No/4e No/3f
    Alphanumeric Yes/4c Yes/4a Yes/4b2 Yes/4b No/4e Yes/3e
    Alphanumeric-Edited Yes/4c Yes/4a No/3a No/3a No/4e No/3f
    Numeric Integer No/3b Yes/4a Yes/4b Yes/4b No/4e No/3f
    Numeric Non-Integer No/3b No/3c Yes/4b Yes/4b No/4e No/3f
    Numeric-Edited No/3b Yes/4a Yes/4b Yes/4b No/4e No/3f
    DBCS national or national-edited No/4e No/4e No/4e No/4e Yes/4e No/3f
    Boolean No/3c Yes/4a No/3b No/3b No/3g Yes/4f
    Note: An error is reported if a non-integer alphanumeric literal sending item is used
Previous Topic Next topic Print topic