MainframeMaster

COBOL PIC & COMP-3 storage calculator

Do not know the PIC yet? Paste a sample value like 20261112 and get suggested PIC / USAGE choices. If you already know the picture, switch to PIC mode for exact bytes, the formula, and a sample 01 declaration.

How to use it

  1. Start in I have a sample value with something real (a date, amount, name, or ID).
  2. Pick a suggested PIC / USAGE (for YYYYMMDD dates that is often 9(8) DISPLAY or X(8)).
  3. Or switch to I know the PIC and enter the picture yourself to confirm storage bytes.

COBOL PIC storage calculator

Examples

What it looks like

Looks like an 8-digit calendar date (YYYYMMDD).

  • This matches a YYYYMMDD-style date (2026-11-12). IBM ACCEPT … DATE YYYYMMDD uses an implicit PIC 9(8).
  • If the field is character text in a file, prefer PIC X(8). If it is a numeric date, prefer PIC 9(8). Only use COMP-3 if the bytes are truly packed decimal.

Suggested PIC / USAGE

Click one to size it in “I know the PIC” mode.

How to choose

If you only know a value like 20261112, start in sample mode. Dates are often PIC 9(8) or PIC X(8). Money usually wants COMP-3 with a V. Then switch to PIC mode to confirm bytes.

Need this at work?

Free account saves tutorial progress. The jobs board lists openings that ask for JCL.

COBOL jobs on the board

Storage rules (quick)

  • DISPLAY: 1 byte per 9/X/A position; +1 byte if SIGN IS SEPARATE
  • COMP / BINARY: 2 bytes (1–4 digits), 4 bytes (5–9), 8 bytes (10–18)
  • COMP-3: ceil((digits + 1) / 2)
  • COMP-5: same byte bands as COMP; wider native binary value range

Explain it like I'm 5

A PIC tells COBOL how many digit or letter slots a field has. USAGE says how those slots are packed in memory. DISPLAY keeps one slot per byte. COMP squeezes numbers into 2, 4, or 8 binary bytes. COMP-3 packs two digits into each byte and saves a tiny corner for the plus/minus sign.

Related concepts

Related pages

Related Pages

FAQ

Sources

Byte bands follow IBM Enterprise COBOL documentation on numeric data formats (DISPLAY, BINARY/COMP, COMP-5, PACKED-DECIMAL/COMP-3) and character-string / item size rules for PICTURE and SIGN SEPARATE.