Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

MOVE statement

Function

The MOVE statement transfers data from one data item to one or more other data items.

Format 1

of the MOVE statement moves one data item to one or more other data items.

Format 2

of the MOVE statement moves corresponding data items from one group to another.

Format 1


MOVE {identifier-1 | literal} TO {identifier-2}...


Syntax rules

  1. An index data item, a data pointer or a data item of class “object” must not appear as an operand of a MOVE statement.

  2. identifier-2 may not be a group data item containing items of the class "object" or "pointer". If identifier-2 is a strongly typed group data item, identifier-1 must be defined as a group data item of the same type.

  3. identifier-1 resp. literal are sending items.

  4. identifier-2 is a receiving item.

  5. The figurative constant SPACE may not be moved to numeric or numeric-edited elementary items.

  6. The figurative constant ZERO may not be moved to alphabetic elementary items.

  7. table 28 shows the moves that are permitted in a MOVE statement and their type.

Receiving item


Sending item

Group

Group Alphabetic

Alphanumeric

National

External decimal,
Binary,
Internal decimal,
Numeric literal

Alphanumeric edited

External fl. point,
Internal fl. point

Strongly typed

Group

nn0

nn0

nn0

-

nn0

nn0

nn0

-

Alphabetic

nn0

nn

nn

nn1

-

nn

-

-

Alphanumeric,
Alphanumeric literal

nn0

nn

nn

nn1

nu2

nn

nu2

-

National, National literal

-

-

-

nn

-

-

-

-

External decimal,
Binary,
Internal decimal,
Numeric literal

integer

nn0

-

nn

nn1

nu

nn

nu

-

non-integer

nn0

-

-

-

nu

-

nu

-

Numeric edited

nn0

-

nn

nn1

nu1

nn

nu1

-

Alphanumeric edited

nn0

nn

nn

nn1

-

nn

-

-

External fl. point

nn0

-

-

-

nu

-

nu

-

Internal fl. point, Fl. point literal

nn0

-

-

-

nu3

-

nu

-

Strongly typed

nn0

nn0

nn0

-

nn0

nn0

nn0

nn01)

Table 28: Legal moves in the case of elementary and group moves2)

1) Only for a receiving item of the same type
2) table entries:

--

=

Move illegal

nn

=

Non-numeric move for elementary items

nn0

=

Non-numeric move for groups (without conversion, without editing, without deediting)

nn1

=

Non-numeric move with conversion of the representation of a character from EBCDIC to UTF-16

nu

=

Numeric move

nu1

=

Numeric move after deediting of the sending item

nu2

=

Numeric move, the sending item being treated as an external decimal elementary item

nu3

=

Numeric move with rounding

General rules

  1. identifier-1 or literal is moved to every data item addressed by identifier-2 in the specified order.

  2. Any subscripting, indexing, reference modification and length calculation associated with identifier-2 is performed immediately before the data is moved to the relevant data item. If identifier-2 is a zero-length item, it is not modified by the MOVE statement.

  3. Any subscripting, indexing, reference modification and length calculation associated with identifier-1 is performed only once before the first move. If identifier-1 is a zerolength item, the MOVE statement is executed as if SPACE were specified as a sending item.

  4. Any necessary conversion of data from one form of internal representation to another takes place during legal moves, along with any editing specified for the receiving data item.

  5. Each move in which the sending item is a literal or an elementary item and the receiving item is also an elementary item is an elementary move. In a MOVE statement in format 1 a national group is treated like an elementary item.

    Any other move is a group move. A group move corresponds to an elementary move with alphanumeric sending and receiving item with the difference that no conversion takes place, i.e. the receiving item is filled without taking into account the group items/data items contained in the sending and receiving items.
    (For special aspects associated with the OCCURS DEPENDING phrase, see general rule 14 of the OCCURS clause on OCCURS clause.)

  6. Any editing specified for the receiving data item takes place during an elementary move (some examples are given below).

  7. Deediting takes place only if the sending item is numeric-edited and the receiving item is numeric or numeric-edited.

  8. There are two types of elementary moves:

    1. A non-numeric move takes place when the receiving item is an alphanumeric edited, alphanumeric, alphabetic, or national item.

      • Alignment and filling with blanks take place in accordance with section "Alignment of data" in section "Concept of computer-independent data description".

      • If the sending item is described as numeric with sign, the sign is not moved. If the sign occupies a character position of its own, it is not moved and the length of the sending item is assumed to be reduced by 1.

      • If the USAGE clause of the sending item differs from that of the receiving item, the sending item is converted for internal representation of the receiving item.

      • If the sending item is numeric and contains the PICTURE symbol 'P', all these character positions are counted in the size of the sending item and it is assumed that they contain the value 0.

    2. A numeric move takes place when the receiving item is a numeric or a numeric edited item.

      • Alignment and filling with blanks take place in accordance with section  "Alignment of data" in section "Concept of computer-independent data description".

      • If the sending item is numeric-edited, it is deedited in order to determine its numeric value. This value is moved to the receiving item.

      • If the receiving item is described with a sign, the sign of the sending item is moved. If the sending item has no sign, a positive sign is generated in the receiving item.

      • If the receiving item as no sign, the absolute value of the sending item is moved and no sign is generated in the receiving item.

      • If the sending item is alphanumeric, it is treated like an external decimal elemtary item. It may only contain numeric characters. If it is longer than 31 characters, only the rightmost 31 characters are used.

  9. Every conversion between different types of internal representation takes place during legal elementary moves. Conversion of alphanumeric to national representation also takes place. If no corresponding national character exists for an alphanumeric character in the sending item in this case, the replacement character "period" is used for this in the receiving item and the exceptional condition EC-DATA-CONVERSION occurs.

    When the exceptional condition EC-DATA-CONVERSION occurs, the receiving item is always modified before any USE procedure that may exist is activated (see also section "NATIONAL-OF - national character representation").

  10. If the sending or receiving operands of a MOVE statement share the same storage area (i.e. if the operands "overlap"), then execution of that statement produces unpredictable results.

  11. Figurative constants are treated like numeric, alphanumeric or national literals depending on the type of receiving item. The table below shows the resultant category of the literal.

    Figurative constant

    Type of receiving item

    Category of the figurative constant

    ALL Alphanumeric literal

    Independent of this

    Alphanumeric

    ALL National literal

    Independent of this

    National

    ALL Symbolic-Character

    Independent of this

    Alphanumeric

    HIGH-VALUE, LOW-VALUE,
    QUOTE

    Group, Alphanumeric,
    Alphanumeric edited

    Alphanumeric

    National

    National

    SPACE

    Group, Alphanumeric, Alphabetic,
    Alphanumeric edited

    Alphanumeric

    National

    National

    ZERO

    Group, Alphanumeric,
    Alphanumeric edited

    Alphanumeric

    National

    National

    External decimal, Binary,
    Internal decimal, Numeric edited,
    External fl. point, Internal fl. point

    Numeric

    Table 29: Moving figurative constants

Example 8-55

Sending item

Receiving item

Statement

PICTURE
IS

Value

PICTURE
IS

Value

XXX

M8N

XXXXX

M8N'BLANK''BLANK'

If no JUSTIFIED RIGHT clause is specified for the receiving item, the characters are moved from left to right. As the data to be moved does not fill the receiving item completely, the remaining positions are filled with blanks .

AAAAAA

XYZABC

AAA

AAA JUST RIGHT

XYZ

ABC

As the sending item is longer than the receiving item, the move is aborted as soon as the receiving item is filled. The remaining characters are ignored.
If the JUSTIFIED RIGHT clause is specified for the receiving item, the characters are moved into the receiving item right-justified.

999PPP

456

XXXXX

45600

Zeros are assumed at positions of the PICTURE symbol ’P’. The sending field consequently has 6 characters. These are moved into the receiving item left-justified. The remaining characters are ignored.

S999

-333

XXX

333

If the sending item has a sign, the absolute value is moved.

9V999

8765

V99

76

The items are aligned on the decimal point. The sending item has more positions to both the left and the right of the decimal point than the receiving item. Positions are truncated at both ends.

9V9

12

99V99

0120

If the receiving item is greater than the sending item, the character positions not used are filled with zeros or editing characters.

99V99

6789

$$$99.99

'BLANK''BLANK' $67.89

S999

-333

9999

333

If the sending item has a sign and the receiving field has none, the absolute value of the sending item is moved.

99

15

999

015

If no assumed decimal point exists, the data is moved to the receiving item right-justified.

XXX

123

99V9

230

The sending item is treated like an integer numeric item with 3 digit positions. There is no space for the leading hundreds positions in the receiving item and it is truncated.

Format 2


MOVE {CORRESPONDINGCORR} identifier-1 TO {identifier-2} ...


Syntax rules

The following rules for identifier-2 also apply to any additional identifiers which follow identifier-2.

  1. CORR is the abbreviation for CORRESPONDING.

  2. identifier-1 specifies a group item which contains the elementary data items to be moved.

  3. identifier-2 specifies a group item which contains the receiving items for the move.

  4. The data items selected from the first operand (identifier-1) are moved to corresponding data items within the second operand (identifier-2). Data items from each group are considered to be corresponding when both data items have the same name and qualification up to, but not necessarily including, identifier-1 and identifier-2.

  5. Any subscripting or indexing associated with identifier-2 is evaluated immediately before the data is moved to the relevant data item.

  6. Any necessary conversion of the data from one form of internal representation to another takes place during legal moves, along with any editing specified for the receiving data item. This is described more fully in the general rules which follow.

General rules

  1. The results of the MOVE CORRESPONDING statement are the same as if the user had specified each pair of corresponding identifiers in a separate MOVE statement of format1 (for further rules see section "CORRESPONDING phrase").

  2. At least one of the data items in each pair of corresponding data items must be an elementary data item (note that the MOVE statement differs from arithmetic statements in this respect: in arithmetic statements using the CORRESPONDING phrase, both corresponding items must be elementary data items).

  3. A data item that is subordinate to identifier-1 or identifier-2 and contains an OCCURS, REDEFINES, USAGE IS INDEX, USAGE IS POINTER, USAGEIS PROGRAM-POINTER, USAGE IS OBJECT REFERENCE or RENAMES clause will be ignored. However, identifier-1 or identifier-2 themselves may have REDEFINES or OCCURS clauses or be subordinate to data items with REDEFINES or OCCURS clauses.

  4. In a MOVE statement in format 2 a national group is treated like a group (and not like an elementary item).

Example 8-56

Procedure Division statement:

MOVE CORRESPONDING EMPLOYEE-RECORD TO PAYROLL-CHECK.

Data Division entries:

01 EMPLOYEE-RECORD.
   02 EMPLOYEE-NUMBER.
      03 PLANT-LOCATION...
      03 CLOCK-NUMBER.
         04 SHIFT-CODE... 
         04 CONTROL-NUMBER...
   02 WAGES.
      03 HOURS-WORKED... 
      03 PAY-RATE... 
   02 FICA-RATE... 
   02 DEDUCTIONS...



01 PAYROLL-CHECK.
   02 EMPLOYEE-NUMBER.
      03 CLOCK-NUMBER...
      03 FILLER...
   02 DEDUCTIONS.
      03 FICA-RATE...
      03 WITHHOLDING-TAX...
      03 PERSONAL-LOANS...
   02 WAGES.
      03 HOURS-WORKED...
      03 PAY-RATE...
   02 NET-PAY...
   02 EMPLOYEE-NAME...
      03 SHIFT-CODE...


According to the MOVE CORRESPONDING rules, the following data items would be moved:

Sending area

Receiving area

CLOCK-NUMBER OF EMPLOYEE- NUMBER OF EMPLOYEE-RECORDCLOCK-NUMBER OF EMPLOYEE-NUMBER OF PAYROLL- CHECK
HOURS-WORKED OF WAGES OF EMPLOYEE-RECORDHOURS-WORKED OF WAGES OF PAYROLL-CHECK
PAY-RATE OF WAGES OF EMPLOYEE-RECORDPAY-RATE OF WAGES OF PAYROLL-CHECK
DEDUCTIONS OF EMPLOYEE-RECORDDEDUCTIONS OF PAYROLL-CHECK

The following items are not moved, for the reasons stated:

Field

Reason

EMPLOYEE-NUMBER

Item is not elementary in either group.

PLANT-LOCATION OF EMPLOYEE-NUMBER OF EMPLOYEE-RECORD

Item does not appear in PAYROLL-CHECK.

SHIFT-CODE OF CLOCK-NUMBER OF EMPLOYEE-NUMBER OF EMPLOYEE-RECORD

Qualification is not identical in PAYROLL-CHECK.

CONTROL-NUMBER OF CLOCK-NUMBER OF EMPLOYEE-NUMBER OF EMPLOYEE-RECORD

Item does not appear in PAYROLL-CHECK.

WAGES

Item is not elementary in either group.

FICA-RATE OF EMPLOYEE-RECORD

Qualification is not identical in PAYROLL-CHECK.