Skip to content
Edit Pictures and Display Formatting
step 1/5

Reading — step 1 of 5

Learn

~2 min readArithmetic and Editing

COBOL's killer reporting feature: edit pictures that format numbers for human readers. Built into the language since 1959.

Zero suppression with Z

       01 N        PIC 9(5)        VALUE 42.
       01 OUTPUT-N PIC ZZZZ9.
           MOVE N TO OUTPUT-N.
           DISPLAY OUTPUT-N.       *> '   42' (3 spaces, then 42)

Z shows the digit if non-zero, replaces with space if leading zero. 9 always shows the digit.

Asterisk fill

       01 OUTPUT-N PIC ****9.
           MOVE 42 TO OUTPUT-N.
           DISPLAY OUTPUT-N.       *> '***42'

Useful for security on checks ("$****42.00" prevents adding zeros).

Currency

       01 PRICE      PIC 9(5)V99   VALUE 1234.56.
       01 OUTPUT-P   PIC $$$,$$9.99.
           MOVE PRICE TO OUTPUT-P.
           DISPLAY OUTPUT-P.       *> '$1,234.56'
  • $$$ — floating dollar sign (rightmost non-blank position)
  • , — thousands separator
  • . — decimal point (must match V in source PIC)

Sign

       01 OUTPUT-N PIC +9999.       *> '+0042' or '-0042'
       01 OUTPUT-N PIC 9999+.       *> trailing sign: '0042+'
       01 OUTPUT-N PIC 9999CR.      *> '0042CR' for negative, '0042  ' for positive
       01 OUTPUT-N PIC 9999DB.      *> '0042DB' / '0042  ' (DB = debit, accounting)

Complete example

       01 GROSS         PIC 9(7)V99    VALUE 12345.67.
       01 GROSS-DISPLAY PIC $$$$,$$9.99.
           MOVE GROSS TO GROSS-DISPLAY.
           DISPLAY GROSS-DISPLAY.    *> '$12,345.67'

Date formatting

       01 DATE-IN       PIC 9(8) VALUE 20260508.
       01 DATE-DISPLAY  PIC 9999/99/99.
           MOVE DATE-IN TO DATE-DISPLAY.
           DISPLAY DATE-DISPLAY.    *> '2026/05/08'

The / is a literal — copies through.

Common edit picture characters

  • 9 — digit, always show
  • Z — digit, replace leading zero with space
  • * — digit, replace leading zero with *
  • $ — currency, floats to leftmost non-zero position
  • , . — separators (literal in output)
  • + - — sign at start
  • + at end — sign at end
  • CR DB — credit/debit indicators (only show on negatives)
  • B — blank (insert space)
  • 0 — literal zero
  • / — literal slash

This is COBOL's gift to financial reporting. Even with modern formatters, edit pictures remain incredibly readable for the cases they cover.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…