skip to main content

Procedure Division Statements : MOVE

MOVE
General Format
Format 1
MOVE { Identifier-1 } TO { Identifier-2 } ... [END-MOVE]
Format 2
MOVE {CORRESPONDING} Identifier-3 TO Identifier-4 [END-MOVE]
     {CORR         }
Format 3
MOVE Identifier-1 TO Identifier-2 WITH {CONVERSION}  
  [ ON EXCEPTION Statement-1 ] 
  [ NOT ON EXCEPTION Statement-2 ] 
[END-MOVE]
Syntax rules
Format 1
1.
2.
3.
4.
5.
6.
7.
When moving National items to Alphabetic or Alphanumeric items, ensure that the destination item is large enough to store the national data according to the current encoding.
Format 2
8.
9.
10.
General rules
Format 1
1.
 
Item identification for identifier-2 is performed immediately before the data is moved to the respective data item. If identifier-2 is a zero-length item, the MOVE statement leaves identifier-2 unchanged.
 
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 length of the data item referenced by identifier-1 is evaluated only once, immediately before the data is moved to the first of the receiving operands. If identifier-1 is a zero-length item, it is as if literal-1 were specified as the figurative constant SPACE.
 
The evaluation of the length of identifier-1 or identifier-2 may be affected by the DEPENDING ON phrase of the OCCURS clause.
 
The result of the statement
is equivalent to:
where 'temp' is an intermediate result item.
2.
 
Any move that is not an elementary move is treated exactly as if it were an alphanumeric to alphanumeric elementary move, except that there is no conversion of data from one form of internal representation to another. In such a move, the receiving area will be filled without consideration for the individual elementary or group items contained within either the sending or receiving area.
3.
 
NOTE - Bit group items and national group items are treated as elementary items in the MOVE statement.
 
The following rules apply:
A.
B.
When the category of the sending operand is other than numeric-edited and the content of the sending operand would result in a false value in a numeric class condition, the results of the execution of the MOVE statement are undefined.
i.
ii.
iii.
a.
b.
c.
4.
 
NOTE - MOVE of alphanumeric figurative constants to numeric items is an archaic feature and its use should be avoided.
Note - When ALL is used, if the receiving item is national, the literal should be escaped, e.g.
MOVE ALL N'B' TO PIECE
Format 2
5.
Data items within identifier-3 are selected to be moved to selected data items within identifier-4 according to the rules specified in the CORRESPONDING phrase. The results are the same as if the user had referred to each pair of corresponding identifiers in separate MOVE statements except that if subscripting is specified for identifier-3 or identifier-4, the subscript value used is that resulting from the evaluation of the subscript at the start of the execution of the statement.
 
NOTE - For purposes of MOVE CORRESPONDING, bit group items and national group items are processed as group items, rather than as elementary items.
Format 3
6.
7.
Examples
Format 1 - Move literals or variables to variables
move 93.5 to num-1 *> num-1 could be pic 9(2)V9(2)
move "hello" to str-1 *> str-1 could be pic x(10)
move num-1 to num-2
move str-1 to str-2 str-3 str-4 *> More than one variables receive the value
move zeroes to num-1 num-2 num3
Format 2 - Move group item to group item with corresponding children items
01 work-hours.
   05 test-hours    pic 9(3value 10.
   05 doc-hours     pic 9(3value 11.
01 total-work-hours.
   05 doc-hours     pic 9(3value 4.
   05 support-hours pic 9(3value 2.
   05 test-hours    pic 9(3value 2.
move corresponding work-hours to total-work-hours
Format 3 - Move with conversion using on exception clause
move "123.456" to str-1                *> str-1 could be pic x(10)
move str-1 to num-1 with conversion    *> num-1 could be pic 9(3)v9(3)
     on exception display message "Move with conversion failed!"
     not on exception display message "Good move"  
Format 3 - Move with conversion using on exception clause
move "12X.B56" to str-1                *> str-1 could be pic x(10)
move str-1 to num-1 with conversion    *> num-1 could be pic 9(3)v9(3)
     on exception display message "Move with conversion failed!"
     not on exception display message "Good move"  
Format 3 - Plain move with conversion
move "123.4" to str-1                 *> str-1 could pib x(10)
move num-1 to str-1 with conversion   *> num-1 could pic 9(3)v9(1)

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left