beautypg.com

Compaq COBOL AAQ2G1FTK User Manual

Page 121

background image

Handling Nonnumeric Data

3.6 Using the MOVE Statement

In the following example, the compiler evaluates FIELD3(FIELD2) immediately
before moving the data into it, but after moving the data from FIELD1 to
FIELD2:

MOVE FIELD1 TO FIELD2 FIELD3(FIELD2).

Thus, it uses the newly stored value of FIELD2 as the subscript value. It is as if
the single MOVE statement were replaced with the following two statements:

MOVE FIELD1 TO FIELD2.

MOVE FIELD1 TO FIELD3(FIELD2).

3.6.5 Common Nonnumeric Item MOVE Statement Errors

The compiler considers any MOVE statement that contains a group item (whether
sending or receiving) to be a group move. If an elementary item contains editing
characters or a numeric integer, these attributes of the receiving item have no
effect on the action of a group move.

3.6.6 Using the MOVE CORRESPONDING Statement for Nonnumeric Items

The MOVE CORRESPONDING statement allows you to move multiple
items from one group item to another group item, using a single MOVE
statement. See the Compaq COBOL Reference Manual for rules concerning the
CORRESPONDING phrase. When you use the CORRESPONDING phrase, the
compiler performs an independent move operation on each pair of corresponding
items from the operands and checks the validity of each. Example 3–2 shows the
use of the MOVE CORRESPONDING statement.

Example 3–2 Sample Record Description Using the MOVE CORRESPONDING

Statement

01 A-GROUP.

01 B-GROUP.

02 FIELD1.

02 FIELD1.

03 A PIC X.

03 A PIC X.

03 B PIC 9.

03 C PIC XX.

03 C PIC XX.

03 E PIC XXX.

03 D PIC 99.
03 E PIC XXX.

MOVE CORRESPONDING

A-GROUP TO B-GROUP.

Equivalent MOVE statements:

MOVE A OF A-GROUP TO A OF B-GROUP.

MOVE C OF A-GROUP TO C OF B-GROUP.

MOVE E OF A-GROUP TO E OF B-GROUP.

Handling Nonnumeric Data 3–11