PROCESSING LITERALS

Literals in COBOL are classified as numeric and alphanumeric. The way they
are handled varies sharply.

Alphanumeric literals:

When alphanumeric data including literals are moved to a field they are
pushed against the left wall of the field leaving any blanks to the right.
For example if WOLF is moved to a six character field it will be stored as
WOLF followed by two spaces. When the programmer actually writes the move
statement, WOLF must be enclosed in quotes. (Most compilers allow either
single or double quotes, some are fussy.)

MOVE "WOLF" TO ANIMAL-PR.

If the programmer wrote MOVE WOLF TO ANIMAL-PR, the compiler would go looking
for a data name in the DATA DIVISION called WOLF so it could move the
contents of the field to the field on the print line.

Literals can also be set up in VALUE clauses and again they must be enclosed
in quotes.

05 DOG-WS
PIC XXX VALUE "DOG".

Numeric literals:

When numeric data including literals are moved to a field they are pushed
against the right wall of the field. The data will be zero filled on the
left. For example, if the programmer moves 212 to a five character field
numeric field it will end up as 00212. When the programmer moves the number
to the numeric field it should not be enclosed in quotes (thereby classifying
the literal as numeric). This is possible because a number can never be
confused with a data name since data names must contain at least one letter.
If the number has a decimal point, it should be included in the literal or
the data will be treated as a whole number. For decimal data, the
destination PIC should contain a V so that alignment will be done correctly.

MOVE 212 TO NUM-WS.
(NUM-WS has a PIC of 999)
MOVE 24.71 TO ANS-WS.
(ANS-WS has a PIC of 99V99)

Numeric literals can also be stored in value clauses. If numeric literals
have decimal places, the location must be specified in both the PIC and the
VALUE. For example, the number 56.78 should be stored using a PIC of 99V99
to indicate the decimal place and the actual decimal place should appear in
the value clause. (Notice that this is different from input data. Input
data is brought in as whole numbers and the V alone establishes the decimal
place. This means that on the data file, the numbers are stored as whole
numbers and the V in the input picture defines which part of the number is
to be treated as a whole number and which part of the number is to be treated
as a decimal number.)

05 AMT1-WS PIC 999
VALUE 123.
05 AMT2-WS PIC 99V99
VALUE 56.78.

Data should not be edited in WORKING-STORAGE or in INPUT areas. Data should
only be edited when it being display on the screen or printed on the printer
for users to read.