Data categories and PICTURE rules

The allowable combinations of PICTURE symbols determine the data category of the item.

The data categories are:

  • Alphabetic
  • Alphanumeric
  • Alphanumeric-edited
  • DBCS
  • External floating-point
  • National
  • National-edited
  • Numeric
  • Numeric-edited

Note: Category internal floating point is defined by a USAGE clause that specifies the COMP-1 or COMP-2 phrase.

Alphabetic items

The PICTURE character-string can contain only the symbol A.

The content of the item must consist only of letters of the Latin alphabet and the space character.

Other clauses

USAGE DISPLAY must be specified or implied.

Any associated VALUE clause must specify an alphanumeric literal containing only alphabetic characters, SPACE, or a symbolic-character as the value of a figurative constant.

Do not include a single byte character in a DBCS data item.

When padding is required for a DBCS data item, the following rules apply:
  • Padding is done using double-byte space characters until the data area is filled (based on the number of double-byte character positions allocated for the data item).
  • Padding is done using single-byte space characters when the padding needed is not an even number of bytes (for example, when an alphanumeric group item is moved to a DBCS data item).

Numeric items

There are several types of numeric items.

The types are:

  • Binary
  • Packed decimal (internal decimal)
  • Zoned decimal (external decimal)
  • National decimal (external decimal)

The type of a numeric item is defined by the usage clause as shown in the table below.

Table 1. Numeric types
Type USAGE clause
Binary BINARY, COMP, COMP-4, or COMP-5
Internal decimal PACKED-DECIMAL, COMP-3
Zoned decimal (external decimal) DISPLAY
National decimal (external decimal) NATIONAL

For all numeric fields, the PICTURE character-string can contain only the symbols 9, P, S, and V.

The symbol S can be written only as the leftmost character in the PICTURE character-string.

The symbol V can be written only once in a given PICTURE character-string.

For binary items, the number of digit positions must range from 1 through 18 inclusive. For packed decimal and zoned decimal items the number of digit positions must range from 1 through 18, inclusive, when the ARITH(COMPAT) compiler option is in effect, or from 1 through 31, inclusive, when the ARITH(EXTEND) compiler option is in effect.

If unsigned, the contents of the item in standard data format must contain a combination of the Arabic numerals 0-9. If signed, it can also contain a +, -, or other representation of the operational sign.

Examples of valid ranges
 PICTURE   Valid range of values
   9999     0 through 9999
    S99    -99 through +99
 S999V9    -999.9 through +999.9
 PPP999     0 through .000999
S999PPP    -1000 through -999000 and
           +1000 through +999000 or zero
Other clauses

The USAGE of the item can be DISPLAY, NATIONAL, BINARY, COMPUTATIONAL, PACKED-DECIMAL, COMPUTATIONAL-3, COMPUTATIONAL-4, or COMPUTATIONAL-5.

For signed numeric items described with usage NATIONAL, the SIGN IS SEPARATE clause must be specified or implied.

The NUMPROC and TRUNC compiler options can affect the use of numeric data items. For details, see NUMPROC and TRUNC in the Enterprise COBOL Programming Guide.

Numeric-edited items

The PICTURE character-string can contain certain symbols.

The symbols are:


B  P  V  Z  9  0  /  ,  .  +  -  CR  DB  *  cs

The combinations of symbols allowed are determined from the PICTURE clause symbol order allowed (see the figure in Symbols used in the PICTURE clause), and the editing rules (see PICTURE clause editing).

The following rules apply:

  • Either the BLANK WHEN ZERO clause must be specified for the item, or the string must contain at least one of the following symbols:
    
    B  /  Z  0  ,  .  *  +  -  CR  DB  cs
    
  • Only one of the following symbols can be written in a given PICTURE character-string:
    
    +  -  CR  DB
    
  • If the ARITH(COMPAT) compiler option is in effect, then the number of digit positions represented in the character-string must be in the range 1 through 18, inclusive. If the ARITH(EXTEND) compiler option is in effect, then the number of digit positions represented in the character-string must be in the range 1 through 31, inclusive.
  • The total number of character positions in the string (including editing-character positions) must not exceed 249.
  • The contents of those character positions representing digits in standard data format must be one of the 10 Arabic numerals.
Other clauses

USAGE DISPLAY or NATIONAL must be specified or implied.

If the usage of the item is DISPLAY, any associated VALUE clause must specify an alphanumeric literal or a figurative constant. The value is assigned without editing.

If the usage of the item is NATIONAL, any associated VALUE clause must specify an alphanumeric literal, a national literal, or a figurative constant. The value is assigned without editing.

Alphanumeric items

The PICTURE character-string must consist of certain symbols.

The symbols are:

  • One or more occurrences of the symbol X.
  • Combinations of the symbols A, X, and 9. (A character-string containing all As or all 9s does not define an alphanumeric item.)

The item is treated as if the character-string contained only the symbol X.

The contents of the item in standard data format can be any allowable characters from the character set of the computer.

Other clauses

USAGE DISPLAY must be specified or implied.

Any associated VALUE clause must specify an alphanumeric literal or one of the following figurative constants:

  • ZERO
  • SPACE
  • QUOTE
  • HIGH-VALUE
  • LOW-VALUE
  • symbolic-character
  • ALL alphanumeric-literal

Alphanumeric-edited items

The PICTURE character-string can contain the following symbols: A X 9 B 0 /.

The string must contain at least one A or X, and at least one B or 0 (zero) or /.

The contents of the item in standard data format must be two or more characters from the character set of the computer.

Other clauses

USAGE DISPLAY must be specified or implied.

Any associated VALUE clause must specify an alphanumeric literal or or one of the following figurative constants:

  • ZERO
  • SPACE
  • QUOTE
  • HIGH-VALUE
  • LOW-VALUE
  • symbolic-character
  • ALL alphanumeric-literal

The literal is treated exactly as specified; no editing is done.

DBCS items

The PICTURE character-string can contain the symbols G, G and B, or N. Each G, B, or N represents a single DBCS character position.

Any associated VALUE clause must contain a DBCS literal, the figurative constant SPACE, or the figurative constant ALL DBCS-literal.

Other clauses

When PICTURE symbol G is used, USAGE DISPLAY-1 must be specified. When PICTURE symbol N is used and the NSYMBOL(DBCS) compiler option is in effect, USAGE DISPLAY-1 is implied if the USAGE clause is omitted.

National items

The PICTURE character-string can contain one or more occurrences of the picture symbol N.

These rules apply when the NSYMBOL(NATIONAL) compiler option is in effect or the USAGE NATIONAL clause is specified. In the absence of a USAGE NATIONAL clause, if the NSYMBOL(DBCS) compiler option is in effect, picture symbol N represents a DBCS character and the rules of the PICTURE clause for a DBCS item apply.

Each N represents a single national character position.

Any associated VALUE clause must specify an alphanumeric literal, a national literal, or one of the following figurative constants:

  • ZERO
  • SPACE
  • QUOTE
  • HIGH-VALUE
  • LOW-VALUE
  • symbolic-character
  • ALL alphanumeric-literal
  • ALL national-literal
Other clauses

Only the NATIONAL phrase can be specified in the USAGE clause. When PICTURE symbol N is used and the NSYMBOL(NATIONAL) compiler option is in effect, USAGE NATIONAL is implied if the usage clause is omitted.

The following clauses can be used:

  • JUSTIFIED
  • EXTERNAL
  • GLOBAL
  • OCCURS
  • REDEFINES
  • RENAMES
  • SYNCHRONIZED
  • Start of changeVOLATILEEnd of change

The following clauses cannot be used:

  • BLANK WHEN ZERO
  • SIGN

National-edited items

The PICTURE character-string must contain at least one symbol N, and at least one instance of one of these symbols: B 0 (zero) or / (slash).

Each symbol represents a single national character position.

Any associated VALUE clause must specify an alphanumeric literal, a national literal, or one of the following figurative constants:

  • ZERO
  • SPACE
  • QUOTE
  • HIGH-VALUE
  • LOW-VALUE
  • symbolic-character
  • ALL alphanumeric-literal
  • ALL national-literal

The literal is treated exactly as specified; no editing is done.

The NSYMBOL(NATIONAL) compiler option has no effect on the definition of a data item of category national-edited.

Other clauses

USAGE NATIONAL must be specified or implied.

The following clauses can be used:

  • JUSTIFIED
  • EXTERNAL
  • GLOBAL
  • OCCURS
  • REDEFINES
  • RENAMES
  • SYNCHRONIZED
  • Start of changeVOLATILEEnd of change

The following clauses cannot be used:

  • BLANK WHEN ZERO
  • SIGN

External floating-point items

A data item is described as category external floating-point by its PICTURE character-string.

The PICTURE character-string details are described below.

Format

Read syntax diagramSkip visual syntax diagram +  - mantissa E +  - exponent
+ or -
A sign character must immediately precede both the mantissa and the exponent.

A + sign indicates that a positive sign will be used in the output to represent positive values and that a negative sign will represent negative values.

A - sign indicates that a blank will be used in the output to represent positive values and that a negative sign will represent negative values.

Each sign position occupies one byte of storage.

mantissa
The mantissa can contain the symbols:

9 . V

An actual decimal point can be represented with a period (.) while an assumed decimal point is represented by a V.

Either an actual or an assumed decimal point must be present in the mantissa; the decimal point can be leading, embedded, or trailing.

The mantissa can contain from 1 to 16 numeric characters.

E
Indicates the exponent.
exponent
The exponent must consist of the symbol 99.

Example: Pic -9v9(9)E-99

The DISPLAY phrase of the USAGE clause and a floating-point picture character-string define the item as a display floating-point data item.

The NATIONAL phrase of the USAGE clause and a floating-point picture character-string define the item as a national floating-point data item.

For items defined with usage DISPLAY, each picture symbol except V defines one alphanumeric character position in the item.

For items defined with usage NATIONAL, each picture symbol except V defines one national character position in the item.

Other clauses

The DISPLAY phrase or the NATIONAL phrase of the USAGE clause must be specified or implied.

The OCCURS, REDEFINES, and RENAMES clauses can be associated with external floating-point items.

The SIGN clause is accepted as documentation and has no effect on the representation of the sign.

The SYNCHRONIZED clause is treated as documentation.

The following clauses are invalid with external floating-point items:

  • BLANK WHEN ZERO
  • JUSTIFIED
  • VALUE