6 using the move statement – Compaq COBOL AAQ2G1FTK User Manual

Page 100

Advertising
background image

Handling Numeric Data
2.6 Using the MOVE Statement

2.6 Using the MOVE Statement

The MOVE statement moves the contents of one item into another item. The
following sample MOVE statement moves the contents of item FIELD1 into item
FIELD2:

MOVE FIELD1 TO FIELD2.

This section considers MOVE statements as applied to numeric and numeric
edited data items.

2.6.1 Elementary Numeric Moves

If both items of a MOVE statement are elementary items and the receiving item
is numeric, it is an elementary numeric move. The sending item can be numeric,
alphanumeric, or numeric-edited. The elementary numeric move converts the
data format of the sending item to the data format of the receiving item.

An alphanumeric sending item can be either of the following:

An elementary alphanumeric data item

Any alphanumeric literal other than the figurative constants SPACE,
QUOTE, LOW-VALUE, or HIGH-VALUE

The elementary numeric move accepts the figurative constant ZERO and
considers it to be equivalent to the numeric literal 0. It treats alphanumeric
sending items as unsigned integers of DISPLAY usage.

When the sending item is numeric-edited, de-editing is applied to establish the
unedited numeric value, which may be signed; then the unedited numeric value
is moved to the receiving field.

If necessary, the numeric move operation converts the sending item to the data
format of the receiving item and aligns the sending item’s decimal point on that of
the receiving item. Then it moves the sending item’s digits to the corresponding
receiving item’s digits.

If the sending item has more digit positions than the receiving item, the decimal
point alignment operation truncates the value of the sending item, with resulting
loss of digits.

The end truncated (high-order or low-order) depends upon the number of sending
item digit positions that find matches on each side of the receiving item’s decimal
point. If the receiving item has fewer digit positions on both sides of the decimal
point, the operation truncates both ends of the sending item. Thus, if an item
described as PIC 999V999 is moved to an item described as PIC 99V99, it loses
one digit from the left end and one from the right end.

In the execution part of the following examples, the caret ( ^ ) indicates the
assumed stored decimal point position:

01 AMOUNT1 PIC 99V99 VALUE ZEROS.

.
.
.
MOVE 123.321 TO AMOUNT1.

Before execution:

00^00

After execution:

23^32

2–6 Handling Numeric Data

Advertising