Using variables
A variable is a data item whose value can change during a program. The value is restricted, however, to the data type that you define when you specify a name and a length for the data item.
About this task
For example, if a customer name is an alphanumeric data item in your program, you could define and use the customer name as shown below:
Data Division.
01 Customer-Name Pic X(20).
01 Original-Customer-Name Pic X(20).
. . .
Procedure Division.
Move Customer-Name to Original-Customer-Name
. . .
You could instead define the customer names above as national
or UTF-8 data items by specifying their
PICTURE
and USAGE
clauses as Pic
N(20)
USAGE NATIONAL
or Pic U(20) USAGE UTF-8
, respectively.
National data items are represented in Unicode UTF-16, in which most characters are represented in 2
bytes of storage. UTF-8 data items are represented in Unicode UTF-8,
which is a variable-width encoding of Unicode, using one to four bytes of storage to represent each
character.
NSYMBOL
Storage of character data
PICTURE clause (Enterprise COBOL for z/OS® Language Reference)