Skip to content

MOVE Statement

The MOVE statement transfers data stored in a source location to one or more named target locations.

Format 1

MOVE identifier-1 TO {data-1} …

Format 2

       MOVE {CORRESPONDING} src-group-item-1 TO target-group-item-1 
            {CORR         }

Syntax:

  1. identifier-n is a data element, literal, or data returned from a function call.
  2. data-n is a data item.
  3. Src-group-item-n and target group item n are group data items containing one or more elementary data items.

General Rules:

  1. A FORMAT 1 MOVE statement may name multiple target data fields.
  2. A FORMAT 1 MOVE from a group item to another group item is treated as a MOVE of an alphanumeric data item to an alphanumeric data item. No check of the validity of the moves at the elementary level is made.
  3. MOVE's to and from USAGE DISPLAY data items perform data conversion using the CODEPAGE module.
  4. The Format 1 MOVE statement allows for the source of the MOVE statement to be MOVE'd to multiple targets. Two sytaxes are supported for a MOVE to multiple targets. Consider the cases where a variable a is being MOVE'd to three target variables b, c, and d:
    • MOVE a TO b,c,d.
    • MOVE a TO b TO c TO d.

      The two statements above are functionally equivalent. That is, in each case, the field a is the source field for the MOVE statement, and the value of a is MOVE'd separately to each of the three target variables b, c, and d.
  5. A Format 2 MOVE statement copies the contents of elements in src-group-item to elements in target group item which are identified as CORRESPONDING data elements.
    • For details on how data items are identified as CORRESPONDING, see the Rules for identifying CORRESPONDING data elements section.
    • A MOVE CORRESPONDING statement first identifies all CORRESPONDING data elements in the src-group-item and target-group-item, and then performs a series of MOVE's from the identified data elements in the src-group-item to their CORRESPONDING data elements in the target group item.
    • CORRESPONDING and CORR are synonyms.
  6. Rules for justification, space filling, decimal point alignment, and zero filling in the target-data-element are described in Rules for Alignment of Data section.
  7. When evaluating the validity of a MOVE statement, the compiler assigns data items/literals to PICTURE DATA CATEGORIES, and then applies certain pre-set rules.
  8. In certain cases, the compiler will report an “ Error: Invalid MOVE statement ”, and abort the compilation:
    • ALPHABETIC data items cannot be MOVE'd to NUMERIC or NUMERIC EDITED data items .
    • NUMERIC/NUMERIC EDITED data items be cannot be MOVE'd to ALPHABETIC data items.
    • ALPHANUMERIC data items cannot be MOVE'd to NUMERIC or NUMERIC EDITED data items.
    • ALPHANUMERIC EDITED data items cannot be MOVE'd to NUMERIC or NUMERIC EDITED data items.
    • NUMERIC non-integer data items cannot be MOVE'd to ALPHANUMERIC or ALPHANUMERIC EDITED data items.
    • NUMERIC EDITED data items cannot be MOVE’d to ALPHANUMERIC data items.
  9. For details on the different PICTURE DATA CATEGORIES, see the Picture Data Categories section. Literals are assigned DATA CATEGORIES according to the following rules:
    • Numeric literals are numeric.
    • All other literals and figurative contants are alphanumeric, with the following exceptions:
      • ZERO is numeric.
      • SPACE is alphabetic.

Code Sample:

       IDENTIFICATION DIVISION. 
       PROGRAM-ID. MOVE-1.
       ENVIRONMENT DIVISION. 
       DATA DIVISION. 
       WORKING-STORAGE SECTION. 
       77 NUMERIC-1         PIC9(5)V9(5) VALUE10. 
       77 NUMERIC-2         PIC9(5)V9(5) VALUE20. 
       01 GROUP-1. 
              03 FLD-1      PIC 99 VALUE 10. 
              03 FLD-2      PIC 99 VALUE 20. 
       01 GROUP-2. 
              03 FLD-1      PIC 99. 
              03 FLD-2      PIC 99. 
       77 DUMMY PIC X. 
       PROCEDURE DIVISION. 
       MAIN. 
              MOVE NUMERIC-1 TO NUMERIC-2. 
              MOVE CORRESPONDING GROUP-1 TO GROUP-2. 
              ACCEPT DUMMY LINE 15 COL 30. 
              STOP RUN.
Back to top