The MOVE statement moves data from one field to another. It packs or unpacks data by moving it to a field with a different data type. When receiving fields are packed, the resultant sign bits are as follows:
- For positive constants and Z/D (zoned decimal) fields -- X'F'
- For positive P/D (packed decimal) fields -- same as field data
- For positive computed fields -- X'C'
- For all negative fields-- X'D'
MOVE does not impose restrictions on the type of data in sending and receiving fields. Data conversion is done only for a P/D or Z/D receiving field when the sending field is P/D, Z/D, or a numeric constant. Other moves proceed left to right in the two fields; the number of bytes moved is the lesser of the sending and receiving field lengths.
If the receiving field is Z/D or P/D and is shorter than the sending field, data on the left is truncated. If the receiving field is alphanumeric and shorter than the sending field or constant, data on the right is truncated.
Moving data of the wrong type to a numeric field (for example, MOVE 'ABC' TO PACKEDFLD) can cause records to be rejected for invalid data, or can ultimately cause a VMRGRW abend.
The MOVE statement does not align decimals. If the receiving field has two decimal places (DISPLAY value ending in '.99') and you move the value '365' to it, the result is interpreted as '3.65'.
The MOVE statement is executed after any SELECT or IGNORE statements in a processing step. If you want to move data before SELECT and IGNORE processing begins, use the NOW MOVE statement instead. For more information, see NOW Keyword.
MOVE "Parms".
Parms:
[sourcefield | literal] TO targetfield [[sourcefieldn | literal] TO targetfieldn] ...
- sourcefield
Specifies the name of a source field to be copied. - literal
Specifies a constant to be copied. - targetfield
Specifies the name of the target field to receive the copied values.
Example
To move the data in field DD3 to field DD2, add this MOVE statement:
MOVE DD3 TO DD2.