beautypg.com

Handling numeric data 2.6 using the move statement – Compaq COBOL AAQ2G1FTK User Manual

Page 102

background image

Handling Numeric Data
2.6 Using the MOVE Statement

For a complete description of these symbols see the Compaq COBOL Reference
Manual
.

The numeric-edited move operation first converts the sending item to DISPLAY
usage and aligns both items on their decimal point locations. The sending item
is truncated or zero-filled until it has the same number of digit positions on both
sides of the decimal point as the receiving item. The operation then moves the
sending item to the receiving item, following the Compaq COBOL editing rules.

The rules allow the numeric-edited move operation to perform any of the following
editing functions:

Replace leading zeros with either spaces or asterisks.

Float a currency sign and a plus or minus sign through suppressed zeros,
inserting the sign at either end of the item.

Insert zeros, spaces, slashes, and/or the symbols CR or DB.

Insert commas and a decimal point (or decimal points and a comma if
DECIMAL-POINT IS COMMA).

Table 2–3 illustrates several of these functions, which are invoked by the
statement:

MOVE FLD-B TO TOTAL-AMT.

Assume that FLD-B is described as S9999V99. Note that the caret ( ^ ) indicates
an assumed decimal point in Table 2–3. In all but two of the examples, the sign
of FLD-B is leading separate. Trailing overpunch signs (the sign of the number
encoded into the rightmost digit) are used in the other two FLD-B data examples.

Table 2–3 Numeric Editing

FLD-B

TOTAL-AMT

PICTURE String

Contents After MOVE

+0023^00

ZZZZ.99

23.00

-0023^00

ZZZZ.99

23.00

0085^9P

++++.99

-85.97

+1234^00

Z,ZZZ.99

1,234.00

+0012^34

$,$$$.99

$12.34

+0000^34

$,$$9.99

$0.34

+1234^00

$$,$$$.99

$1,234.00

+0012^34

$$9,999.99

$0,012.34

+0012^34

$$$$,$$$.99

$12.34

+0000^00

$$$,$$$.$$

0012^3M

++++.99

-12.34

+0012^34

$***,***.99

$*****12.34

+1234^56

Z,ZZZ.99+

1,234.56+

(continued on next page)

2–8 Handling Numeric Data