Appendix F: PICTURE Clause Reference

Overview

The PICTURE clause (abbreviated PIC) is COBOL's mechanism for defining the type, size, and format of elementary data items. Unlike modern languages that select from predefined types (int, float, string), COBOL programmers construct a character-by-character description of exactly how each data item is stored and displayed. This appendix provides a complete reference for PICTURE clause symbols, rules, and common patterns.


1. PICTURE Clause Categories

Every PICTURE clause falls into one of five categories:

Category Purpose Symbols Allowed
Numeric Stores numeric values for arithmetic 9, S, V, P
Alphabetic Stores only letters and spaces A
Alphanumeric Stores any character X
Numeric Edited Formats numeric values for display 9, Z, *, $, +, -, CR, DB, B, 0, /, comma, period
Alphanumeric Edited Formats alphanumeric values for display X, A, 9, B, 0, /

2. Numeric Symbols

These symbols define data items that participate in arithmetic operations.

9 (Digit)

Represents a single decimal digit position (0--9). Each 9 occupies one byte in DISPLAY format.

PIC 9(5)       Five-digit unsigned integer (00000-99999)
PIC 99999      Same as above (expanded notation)

S (Sign)

Indicates that the data item can hold a positive or negative value. Must appear as the first character of the PICTURE string. Without S, the item is treated as unsigned (absolute value).

PIC S9(5)      Signed five-digit integer (-99999 to +99999)
PIC S9(7)V99   Signed with two decimal places

The sign storage depends on the USAGE clause: - DISPLAY: Sign is stored as a sign overpunch in the last byte (or leading separate if SIGN IS LEADING SEPARATE) - COMP-3: Sign is stored in the low nibble of the last byte - COMP/BINARY: Sign is stored as part of the binary value (two's complement)

V (Implied Decimal Point)

Marks the position of the decimal point within a numeric item. The decimal point is not stored in memory; it exists only in the compiler's knowledge for alignment during arithmetic. Only one V is permitted per PICTURE clause.

PIC 9(5)V99    Five integer digits, two decimal digits (7 bytes in DISPLAY)
PIC V99        No integer digits, two decimal places
PIC 9(7)V      Seven integer digits, no decimal places (same as PIC 9(7))

P (Decimal Scaling Position)

Represents an assumed decimal digit position that is not stored in memory, used for values where the implied decimal point falls outside the stored digits. P positions are always at the left or right end of the PICTURE string.

PIC 9(3)PPP    Stored as 3 digits, but value is multiplied by 1000
               (e.g., stored 123 represents 123000)
PIC PPP9(3)    Stored as 3 digits, but value is divided by 1000000
               (e.g., stored 456 represents 0.000456)

P is rarely used in practice but appears in some financial and scientific applications where precision optimization is needed.


3. Alphabetic Symbol

A (Letter or Space)

Represents a single alphabetic character (A--Z, a--z) or a space. Each A occupies one byte.

PIC A(20)      Twenty alphabetic characters
PIC AAA        Three alphabetic characters

Alphabetic items are uncommon in modern COBOL; most character data uses alphanumeric (X) instead, since real-world data often contains mixed characters.


4. Alphanumeric Symbol

X (Any Character)

Represents a single character position that can hold any character in the character set. Each X occupies one byte.

PIC X(50)      Fifty-character alphanumeric field
PIC XX         Two-character field
PIC X          Single character

Alphanumeric items are the most common category for non-numeric data: names, addresses, descriptions, codes, and identifiers.


5. Numeric Edited Symbols

Numeric edited items format numeric values for human-readable output. They cannot be used in arithmetic operations.

Z (Zero Suppress)

Replaces leading zeros with spaces. Each Z represents one digit position.

PIC Z(5)       Five digits with leading zero suppression
PIC ZZZZ9      Four suppressed positions, last digit always shown
PIC ZZ,ZZZ     Suppressed with comma insertion (comma suppressed if all preceding digits are zero)

* (Asterisk / Check Protect)

Replaces leading zeros with asterisks. Used on financial documents (checks) to prevent fraud by filling unused digit positions.

PIC **,***.**  Check-protected currency format
PIC ****9      Four protected positions, last digit always shown

$ (Currency Sign)

Inserts a currency symbol in the output.

  • Fixed: A single $ at the beginning always appears in that position
  • Floating: Multiple $ symbols cause the $ to float to the position immediately before the first significant digit
PIC $9,999.99       Fixed dollar sign: $0,123.45
PIC $$,$$$.99       Floating dollar sign:    $123.45
PIC $$$,$$$.99      Floating with wider range: $123,456.99

+ (Plus Sign)

Inserts a sign indicator. Shows + for positive values and - for negative values.

  • Fixed: A single + at the beginning or end appears in that position
  • Floating: Multiple + symbols cause the sign to float to the position before the first significant digit
PIC +9(5)      Fixed leading sign: +00123 or -00123
PIC 9(5)+      Fixed trailing sign: 00123+ or 00123-
PIC ++,+++     Floating sign: +1,234 or -1,234

- (Minus Sign)

Similar to + but displays a minus sign for negative values and a space for positive values.

  • Fixed: A single - at the beginning or end
  • Floating: Multiple - symbols cause the sign to float
PIC -9(5)      Fixed leading: -00123 or  00123 (space for positive)
PIC 9(5)-      Fixed trailing: 00123- or 00123  (space for positive)
PIC --,---     Floating:  1,234 or -1,234

CR (Credit) and DB (Debit)

Appear at the end of the PICTURE string. CR or DB is displayed when the value is negative; spaces are displayed when the value is positive or zero. Used in accounting reports.

PIC 9(5).99CR  Displays: 00123.45   (positive) or 00123.45CR (negative)
PIC 9(5).99DB  Displays: 00123.45   (positive) or 00123.45DB (negative)

, (Comma / Grouping Separator)

Inserts a comma at the specified position for thousands grouping. When preceded by zero-suppressed positions (Z or ) and all preceding digits are zero, the comma is replaced by a space (Z) or asterisk ().

PIC 9,999,999  Always shows commas: 1,234,567
PIC Z,ZZZ,ZZ9  Suppressed with grouping:     1,234 or         5

. (Period / Decimal Point)

Inserts an actual decimal point character in the output. Only one period is allowed per PICTURE clause. The period defines the decimal alignment position (replaces the function of V in edited items).

PIC ZZZ,ZZ9.99    Edited with decimal point: 123,456.78
PIC ***,***.99     Check-protected: ***,123.99

Important: If the DECIMAL-POINT IS COMMA clause is specified in SPECIAL-NAMES, the roles of comma and period are exchanged throughout the program.

B (Blank Insertion)

Inserts a space character at the specified position.

PIC 99B99B99   Date-like format: 12 31 99
PIC X(10)BX(10)  Two fields separated by a space

0 (Zero Insertion)

Inserts a literal zero character at the specified position.

PIC 9(3)0(2)   Appends two zeros: 12300 (for input 123)
PIC 909090     Inserts zeros between digits

/ (Slash Insertion)

Inserts a slash character at the specified position. Commonly used for date formatting.

PIC 99/99/9999  Date format: 12/31/2025
PIC 99/99/99    Short date: 12/31/25

6. Rules and Restrictions

  1. Maximum PICTURE length: The character string can define up to 18 digit positions (9, Z, *, or floating symbols).
  2. V and . are mutually exclusive: An edited item uses . for the decimal point; a computational item uses V.
  3. S is for computational items only: S cannot appear in edited PICTURE strings. Use +, -, CR, or DB for edited sign display.
  4. Only one floating symbol type: A PICTURE clause can have only one type of floating symbol ($, +, or -), not a combination.
  5. 9 after Z restriction: Once Z appears in a PICTURE string, 9 can only appear in positions to the right of the decimal point (except for the rightmost position to ensure at least one digit is shown). Example: PIC ZZZ9 is valid; PIC Z9Z9 is invalid.
  6. COMP-3 and COMP items do not use edited symbols: Edited PICTURE clauses apply only to DISPLAY USAGE items.
  7. Repetition factor: Parentheses indicate repetition. PIC 9(5) equals PIC 99999. Repetition factors can appear with any symbol: PIC X(100), PIC Z(6).
  8. Alphanumeric edited: Items mixing X, A, or 9 with B, 0, or / are classified as alphanumeric edited. These are uncommon but valid.

7. USAGE Clause Interaction

The USAGE clause determines how the PICTURE data is physically stored:

USAGE Storage Bytes per Digit Arithmetic Notes
DISPLAY Zoned decimal / character 1 byte per digit or character Yes (inefficient) Default if USAGE not specified
COMP / BINARY Binary (two's complement) 2, 4, or 8 bytes total Yes (efficient for integers) PIC 9(1-4)=2 bytes, 9(5-9)=4 bytes, 9(10-18)=8 bytes
COMP-3 / PACKED-DECIMAL Packed decimal 2 digits per byte + sign nibble Yes (exact decimal; ideal for money) PIC 9(n) uses CEIL((n+1)/2) bytes
COMP-5 Native binary 2, 4, or 8 bytes Yes Value range limited by byte size, not PIC
INDEX Internal address format 4 or 8 bytes No For SEARCH/SET operations on tables

8. Complete Examples

The following table shows common business data patterns with their PICTURE clause definitions, sample stored values, and displayed output.

Numeric (Computational) Items

Description PICTURE Clause USAGE Sample Value Stored As
Employee ID PIC 9(6) DISPLAY 004521 F0F0F4F5F2F1 (EBCDIC)
Account balance PIC S9(9)V99 COMP-3 +123456.78 01 23 45 67 8C (6 bytes)
Quantity PIC 9(5) COMP 250 00FA (2 bytes binary)
Interest rate PIC V9(7) COMP-3 .0525000 05 25 00 0C (4 bytes)
Negative amount PIC S9(7)V99 COMP-3 -5432.10 00 54 32 10 0D (5 bytes)
Transaction code PIC 9(2) DISPLAY 07 F0F7 (EBCDIC)
Large currency PIC S9(13)V99 COMP-3 +1234567890.12 01 23 45 67 89 01 2C (8 bytes)

Alphanumeric Items

Description PICTURE Clause Size Sample Value
Customer name PIC X(30) 30 bytes SMITH, JOHN J.
Address line PIC X(50) 50 bytes 123 MAIN STREET APT 4B
State code PIC X(2) 2 bytes NY
Filler/padding PIC X(5) 5 bytes (spaces)
Flag field PIC X 1 byte Y

Numeric Edited Items (Display Output)

Description PICTURE Clause Input Value Displayed Output
Whole number, zero-suppressed PIC Z(6)9 42 " 42"
Currency, fixed $ | PIC $9,999,999.99 1234567.89 "$1,234,567.89"
Currency, floating $ | PIC MATH2$,$$$.99 | 1234.56 | " $1,234.56" | | Currency, floating $ | PIC $$,$$$,$$$.99 | 0.50 | " $.50"
Check-protected amount PIC $**,***,***.99 | 1234.56 | "$*1,234.56"
Signed, leading + PIC +ZZ,ZZ9.99 -1234.56 " -1,234.56"
Signed, leading + PIC +ZZ,ZZ9.99 1234.56 " +1,234.56"
Signed, trailing - PIC ZZ,ZZ9.99- -42.00 " 42.00-"
Signed, trailing - PIC ZZ,ZZ9.99- 42.00 " 42.00 "
Credit indicator PIC Z,ZZZ,ZZ9.99CR -5000.00 " 5,000.00CR"
Credit indicator PIC Z,ZZZ,ZZ9.99CR 5000.00 " 5,000.00 "
Debit indicator PIC Z,ZZZ,ZZ9.99DB -750.25 " 750.25DB"
Percentage PIC ZZ9.99 5.25 " 5.25"
Date with slashes PIC 99/99/9999 12312025 "12/31/2025"
Date with hyphens (uses B) PIC 99B99B9999 12312025 "12 31 2025"
Social Security Number PIC 999-99-9999 123456789 "123-45-6789"
Phone number PIC (999)B999-9999 2125551234 "(212) 555-1234"
Zero-fill PIC 9(3)0(4) 123 "1230000"

Note on the phone number example: The parentheses in the phone number PIC clause are literal insertion characters (not repetition factors) when used with alphanumeric edited items. For portable numeric editing, consider using STRING or reference modification instead.

Common Business Data Patterns

Business Use Data Name PIC Clause USAGE Example Value
Dollar amount (storage) WS-AMOUNT PIC S9(9)V99 COMP-3 12345.67
Dollar amount (display) WS-AMOUNT-DISP PIC $$$,$$$,MATH6MATH7$,$$$.99CR DISPLAY " $1,234,567.89 "

9. Quick Reference Card

Numeric (for arithmetic):

9    Digit position
S    Signed (must be first)
V    Implied decimal point
P    Decimal scaling (assumed zero)

Character:

X    Any character
A    Letter or space only

Numeric Edited (for display):

Z    Zero-suppress to space
*    Zero-suppress to asterisk
$    Currency sign (fixed or floating)
+    Sign: shows + or - (fixed or floating)
-    Sign: shows - or space (fixed or floating)
CR   Credit: shows CR or spaces (trailing only)
DB   Debit: shows DB or spaces (trailing only)
,    Comma insertion (grouping separator)
.    Decimal point insertion
B    Blank (space) insertion
0    Zero insertion
/    Slash insertion

USAGE summary:

DISPLAY      Default; character representation; 1 byte per digit/char
COMP-3       Packed decimal; 2 digits per byte; exact arithmetic for money
COMP/BINARY  Binary; 2/4/8 bytes; efficient for counters and indexes
COMP-5       Native binary; full byte-range values

10. Common Mistakes

  1. Forgetting S on signed items: Without S, moving -100 to PIC 9(3) stores 100 (absolute value). Always use S for items that may hold negative values.

  2. Using V in edited items: PIC Z(5)V99 is incorrect for display. Use PIC Z(5).99 with a real decimal point for edited output.

  3. Arithmetic on edited items: PIC $ZZ,ZZ9.99 cannot be used in ADD, SUBTRACT, MULTIPLY, DIVIDE, or COMPUTE. Move the value to an edited item only for display.

  4. COMP-3 size miscalculation: PIC S9(7) COMP-3 uses 4 bytes, not 7. The formula is CEIL((n+1)/2) where n is the number of digit positions.

  5. Truncation vs. rounding: Moving 123.456 to PIC 9(3)V99 stores 123.45 (truncated, not rounded). Use the ROUNDED phrase in arithmetic statements to control rounding behavior.

  6. Insufficient integer digits: Moving 12345 to PIC 9(3) stores 345 (truncation of high-order digits). Always allocate enough digit positions for the maximum expected value.

  7. Mixing 9 and Z incorrectly: PIC Z9Z9 is invalid. Once zero suppression begins, it must continue (except for the rightmost digit if using ZZZ9 pattern).

  8. Missing DECIMAL-POINT IS COMMA: In European locales where comma is the decimal separator and period is the grouping separator, specify DECIMAL-POINT IS COMMA in SPECIAL-NAMES. This reverses the roles of comma and period in all PICTURE clauses.