MOVE statement

The MOVE statement is supported by Migration Utility in two ways. The type of move is controlled via the EASYTRAN/EZPARAMS MOVENUM= option.

  1. When MOVENUM=NATIVE is in effect, the MOVE is generated to use native COBOL rules.
  2. When MOVENUM=EASYT is in effect, the MOVE is generated according to Easytrieve Plus rules.

The COBOL MOVE statement does not directly correspond to the Easytrieve Plus MOVE. The COBOL MOVE behaves like the Easytrieve Plus ASSIGN statement. That is, the field types are considered and converted during the move, while the Easytrieve Plus MOVE statement moves data as is (without conversion).

The MOVE statement transfers data strings from one storage location to another. The MOVE statement is specially useful for moving data without conversion and for moving variable-length fields. There are two MOVE statement formats.

Format 1

Read syntax diagramSkip visual syntax diagramMOVE&SENDFILE&SENDRECORD&SENDFIELD&SENDLITERAL&START-POS&SEND-LENGTHTO&RECEIVEFILE&RECEIVERECORD&RECEIVEFIELD&START-POS&RECEIVE-LENGTHFILL' &FILLCHR'MASK' &MASK'HEXFILL&FILLCHRLENGTH&STRING-LENGTH
Parameters
Source data identifier
You can use one of the following values:
&SENDFILE
A file name defined in the Library Section. Referencing a file name results in a move of the current file record.
&SENDRECORD
A record name or working storage area
&SENDFIELD
A currently available field name
&SENDLITERAL
A literal. Alphanumeric literals must be enclosed in quotation marks.
&START-POS
Start position within the sending field. This is a special Migration Utility feature not supported by Easytrieve Plus.
&SEND-LENGTH
Length of the sending field. It can be a numeric literal or a field name.
Target location identifier
You can use one of the following values:
&RECEIVEFILE
A file name defined in the Library Section. Referencing a file name results in a move into the current file record.
&RECEIVERECORD
A record name or working storage area
&RECEIVEFIELD
A currently available field name
&START-POS
Start position within the receiving field. This is a special Migration Utility feature not supported by Easytrieve Plus.
&RECEIVE-LENGTH
Length of the receiving field. It can be a numeric literal or a field name.
&FILLCHR
A pad character. This character is used to pad the target object if the sending object is shorter than the receiving object. The default is spaces. &FILLCHR can be a field name or a 1-character literal enclosed in quotes.
&MASK
A mask for the receiving field. (This is a Migration Utility extension to MOVE.)
The mask can be:
  • Any valid edit mask with insert characters up to 30 characters long.
  • HEX for conversion to hexadecimal.

The sending field can be a numeric or an alphanumeric field. The receiving field must be an alphanumeric field (a type A field).

When you use '&MASK', the contents of the sending field are edited into the receiving field according to the mask.

When you specify HEX, the contents of the sending field are converted to the hexadecimal equivalent and placed into the receiving field.

If you do not specify a mask, the contents of the sending field are edited into the receiving field according to the default mask of the sending field.

The MASK option is useful for formatting fields for a spreadsheet or for inserting special characters into a data string.

&FILLCHR
A pad character. This character is used to replace trailing spaces in &RECEIVEFIELD. Trailing spaces are replaced for alphanumeric masks only.
For example:
FIELDA   W     10  VALUE '12345'
FIELDB   W     10  VALUE SPACES

MOVE FIELDA TO FIELDB MASK 'X(10)' FILL '*'
After completion, FIELDB contains 123456****.
&STRING-LENGTH
After the MOVE statement has been completed, contains the length of &RECEIVEFIELD, excluding the trailing spaces.

Can be a binary, display, or packed decimal field.

If FILL &FILLCHR are specified, &STRING-LENGTH contains the length of &RECEIVEFIELD, excluding the &FILLCHR pad character.

For numeric masks, &STRING-LENGTH contains the length of &MASK.

Example 1:
FIELDA   W     10  VALUE '123456'
FIELDB   W     10  VALUE SPACES
WLENGTH  W      2  B

MOVE FIELDA TO FIELDB MASK 'X(10)' FILL X'*' LENGTH WLENGTH
After completion, FIELDB contains 123456**** and WLENGTH contains 6.
Example 2:
FIELD1   W     10  VALUE '123456'
FIELD2   W     10  VALUE SPACES
WLENGTH  W      2  B

MOVE FIELD1 TO FIELD2 MASK 'ZZZ,ZZ9' LENGTH WLENGTH
After completion FIELD2 contains 123,456 and WLENGTH contains 7.
The following example show the effect of using a mask:
FIELD-1      W       5   N    VALUE  -123   MASK ('99-99-99')
FIELD-2      W      10   A    VALUE SPACES
FIELD-3      W      10   A    VALUE SPACES
FIELD-4      W      10   A    VALUE SPACES
FIELD-5      W      10   A    VALUE SPACES

MOVE FIELD-1 TO FIELD-2 MASK '----9'
MOVE FIELD-1 TO FIELD-3 MASK HEX
MOVE FIELD-1 TO FIELD-4 MASK
MOVE FIELD-1 TO FIELD-5 MASK 'ZZZZZCR'
After the move, the contents of the receiving fields are:
FIELD-2
-123
FIELD-3
F0F0F1F2D3
FIELD-4
00-01-23
FIELD-5
123CR

Format 2

Read syntax diagramSkip visual syntax diagramMOVENULLSPACESPACESZEROZEROSZEROESTO&RECEIVEFIELD
Parameters
The first parameter identifies the sending data area.
The default length is the length of the receiving field. Moving SPACE or SPACES fills the field with all spaces. Moving NULL fills the field with low values, and moving ZERO, ZEROES or ZEROS moves all zeros to the field.
&RECEIVEFIELD
One or more receiving fields. The receiving field is set to the proper data format. However, you cannot move spaces into a packed field or a binary field.

Easytrieve Format 1 data is moved from left to right as if both areas were alphanumeric. The data moved is not converted. It is moved as is, even if the from and to fields are packed or binary fields.

When MOVENUM=NATIVE is in effect, Migration Utility Format 1 generates standard COBOL MOVEs. The data is moved according to the standard COBOL Conversion rules so a move from a binary field into a display numeric field results in data conversion from binary to Display Numeric format, yielding a result that differs from the Easytrieve MOVE. Compatible results can be achieved by redefining the numeric field as an alpha field and using the alpha field name as the source or target in the MOVE statement.