Data Types & PICTURE Clauses

COBOL Fundamentals

Chapter 3 · Data Types & PICTURE Clauses

Chapter 2's own 01 WS-GREETING PIC X(20) VALUE "HELLO, COBOL". line already used three real pieces this chapter covers properly: a level number, a PICTURE clause, and a VALUE clause. Chapter 1 also already traced the PICTURE clause's own real origin to COMTRAN — this chapter shows exactly what it can express, and one real, easy-to-miss detail about how COBOL actually stores the numbers behind it.

Level Numbers: Building Hierarchical Records

COBOL data items are organized hierarchically using real, numbered levels — an item with a higher level number is subordinate to an item with a lower one.

LevelReal Meaning
01Begins a record definition — the top of a hierarchy
05, 10, 15…Nested subordinate items underneath an 01 (or another subordinate level)
77A standalone field with no subordinate items at all
88A condition name — a real, named shortcut for testing whether another field holds a specific value, covered fully in Chapter 5

The Real PICTURE Clause Symbols

SymbolReal Meaning
9A decimal digit (0–9)
XAny character — alphanumeric
AAlphabetic characters only (letters or spaces)
VThe implied decimal point's location — not actually stored
SMarks the item as signed (positive or negative)

A count like 9(5) means "five real occurrences of 9" — five digits — the same shorthand Chapter 2's own X(20) already used for twenty characters.

A Real, Easy-to-Miss Detail: The Implied Decimal Point

Take PIC 9(5)V9(2) — a real, valid field with 5 digits before the decimal and 2 after, 7 digits total. Storing the value 12345.67 in it does not store a decimal point character anywhere.

What's Actually in Memory Internally, this field genuinely holds just the digit sequence 1234567 — seven raw digits, no decimal point. The V only tells COBOL where the decimal point belongs when the value is interpreted or displayed; it never occupies real, physical storage space of its own.
Why This Matters for Reading Legacy Code This is one of the first real surprises many newcomers hit reading existing COBOL: a field's own raw stored digits will never contain a decimal point, even when the PICTURE clause clearly implies one. Arithmetic on the field works correctly regardless — COBOL applies the implied decimal position automatically — but a raw dump of the underlying storage will never show it.

USAGE Clauses: How Data Is Actually Stored

A field's USAGE clause controls its real, physical storage format — separate from what its PICTURE clause describes.

UsageReal Storage FormatWhy It's Used
DISPLAY (default)One byte per character/digit, human-readableSimple, but real, genuinely wasteful for large numeric fields
COMP / COMPUTATIONALOften equivalent to native binary storageReal, faster arithmetic and more compact storage
COMP-3 / PACKED-DECIMALPacked binary-coded decimal — two digits per byteReal mainframe storage efficiency, still extremely common in legacy business data

On real mainframes, where storage space directly affected cost, COMP-3 in particular became genuinely standard for business numeric fields — expect to see it constantly once Chapter 8 starts reading real file records.

Putting It Together

01 WS-CUSTOMER-RECORD. 05 WS-CUSTOMER-ID PIC 9(6). 05 WS-CUSTOMER-NAME PIC X(30). 05 WS-BALANCE PIC S9(7)V99 COMP-3 VALUE 0.

One 01-level record, three real subordinate 05-level fields: a plain numeric ID, a text name, and a signed, two-decimal-place balance stored efficiently as packed decimal — a real, small-scale preview of exactly the kind of record layout Chapter 8's own file-handling material builds on directly.

Hands-On Exercises

Exercise 1

Using this chapter's own real material, explain in your own words what the raw stored digits would be for the value 4210.5 in a field defined as PIC 9(5)V9(1), and why a decimal point never appears among those stored digits.

📄 View solution
Exercise 2

A colleague says, "COMP-3 and PIC are basically the same kind of thing — they both describe a field's data type." Using this chapter's own real material, explain in your own words why this isn't accurate.

📄 View solution
Exercise 3

Using this chapter's own real worked WS-CUSTOMER-RECORD example, explain in your own words the real hierarchical relationship between the 01-level item and each of the three 05-level items beneath it.

📄 View solution

Chapter 3 Quick Reference

  • Level numbers: 01 (record) → 05/10/15… (subordinate) · 77 (standalone) · 88 (condition name, Chapter 5)
  • PICTURE symbols: 9 (digit) · X (any character) · A (alphabetic) · V (implied decimal, not stored) · S (signed)
  • Real gotcha: PIC 9(5)V9(2) holding 12345.67 stores just 1234567 — no decimal point character, ever
  • USAGE: DISPLAY (default, human-readable) · COMP/COMPUTATIONAL (binary) · COMP-3/PACKED-DECIMAL (packed BCD, real mainframe storage efficiency)