Using literals
A literal is a character string whose value
is given by the characters themselves. If you know the value you want
a data item to have, you can use a literal representation of the data
value in the PROCEDURE DIVISION
.
About this task
You do not need to define a data item for the value nor refer to it by using a data-name. For example, you can prepare an error message for an output file by moving an alphanumeric literal:
Move "Name is not valid" To Customer-Name
You can compare a data item to a
specific integer value by using a numeric literal. In the example
below, "Name is not valid"
is an alphanumeric literal,
and 03519
is a numeric literal:
01 Part-number Pic 9(5).
. . .
If Part-number = 03519 then display "Part number was found"
You
can use hexadecimal-notation format (X'
) to express
control characters X'00'
through X'1F'
within
an alphanumeric literal. Results are unpredictable if you specify
these control characters in the basic format of alphanumeric literals.
You
can use the opening delimiter N"
or N'
to
designate a national literal if the NSYMBOL(NATIONAL)
compiler
option is in effect, or to designate a DBCS literal if the NSYMBOL(DBCS)
compiler
option is in effect.
You can
use the opening delimiter NX"
or NX'
to
designate national literals in hexadecimal notation (regardless of
the setting of the NSYMBOL
compiler option). Each
group of four hexadecimal digits designates a single national character.