Previous Topic: LOCATE

Next Topic: MOVE (Format II)

MOVE (Format I)

The purpose of the MOVE statement is primarily to move data to construct key values for the subsequent retrieval of a record from the database. Review the chapter "Moving Data to Construct Key Values" for an explanation of this process. Only simple fields are supported. There are two versions of the MOVE statement.

The format I MOVE simply moves data fields of the same length and data type.

The format II MOVE supports moving data fields of different lengths and provides justifying and/or padding options.

MOVE Statement (format I)

*DM MOVE {field-name1(qualifier) | literal} TO field-name2(qualifier).
Field-name

Depending on where the data resides, this can be either a COBOL field name (see the chapter on "Copying Record Descriptions"), a COBOL field name defined in the DATAMACS-WORK-AREA, or a key field occurrence name. It may be necessary to qualify the field name because of its location (see the chapter "Moving Data to Construct Key Values").

A field name is 'qualified' when certain information is appended to a field name by enclosing it in parenthesis and separating multiple keywords by a comma.

CA-Datamacs/II assumes the following default MOVE.

MOVE COBOL-field-name TO COBOL-field-name.

It is assumed the move will transfer the data from the input buffer to a field located in the output buffer. It can be the same field name. In this case, a shortcut is available, simply code an asterisk(*) in place of the second field name (for example, MOVE field-name1 TO *.). There is an exception to the default if either field name resides in the DATAMACS-WORK-AREA, this will be detected and the target address will be adjusted accordingly.

COBOL field names only describe the contents of the input/output buffers and the DATAMACS-WORK-AREA.

Only the simple key field occurrences are used to describe the contents of the key value areas.

The other qualifier options are:

  1. If the target field is a repeating field (the COBOL OCCURS x TIMES), specify this as a numeric qualifier (for example, field-namex(3)).
  2. If the COBOL field resides in the output buffer, qualify it with field-namex(OUTPUT).
  3. If it is a COBOL repeating field and is in the output buffer, qualify it with field-namex(3,OUTPUT). The repeat factor must always be entered first.
  4. If it is a key field occurrence name, it must be qualified with the table name and key occurrence name (for example, key-field(table-name,key-occ)).
  5. If it is a key field occurrence and it must be moved to the second key value area to end the key range, qualify it as key-field(table-name,key-occ,RANGE).
  6. If the COBOL field name is duplicated, qualify it with field-name(table-name).

Rules for continuing long names:

A field qualifier must always start with a left parenthesis.

If the field name and its qualifier are on the same line, the left parenthesis starting the qualifier must immediately follow the field name, without a space.

It is permitted to start the qualifier on a line by itself.

To separate qualifiers onto separate lines, end the first one with a comma, and continue the remainder on the next line.

The right parenthesis can never be left hanging by itself.

Examples:

MOVE key-field1(table-name1,key-occurrence1) TO
     key-field2
     (table-name2,key-occurrence2,RANGE).

MOVE key-field1(table-name1,key-occurrence1) TO key-field2 (table-name2, key-occurrence2).

Literals

Literals are only supported in the first operand.

The literal and its delimiting characters must not exceed 256 bytes.

Multiple literals on separate lines will be concatenated as though they were all entered on one line. The separator word TO will signify the end of the literal. Code a zoned decimal numeric literal as a numeric integer.

Code an alphanumeric literal enclosed in quotes.

Code a hexadecimal literal enclosed in quotes with a preceding X.

Code packed decimal numeric data in the hexadecimal format, being careful to use the sign consistent with the Datadictionary definition.

Figurative constants are only supported in the first operand.

ZEROES, ZERO, ZEROS

SPACE, SPACES

HIGH-VALUES

LOW-VALUES

The figurative constant is translated to a literal with a length determined by the second field name.

No data conversion is performed when the data types differ.

The TO option precedes the receiving field and must follow the source field.

A period must signify the end of the MOVE statement.

If the field lengths differ, the length of the shortest field will govern the move.

Because each record is held in its own unique work area, it is possible to move field contents between records of different tables without using an intermediate save field.