Edited pictures
A number stored as PIC S9(5)V99 is great for arithmetic but useless on
a report: -0123450 with an invisible decimal point. Edited pictures
turn numbers into human-readable text. You MOVE a numeric value into an
edited field, and the picture decides how it looks.
Suppression, separators and currency
| Symbol | Effect |
|---|---|
Z |
Replace a leading zero with a space |
* |
Replace a leading zero with * (cheque protection) |
. |
An actual decimal point, printed |
, |
A comma, printed (becomes a space or * inside suppressed zeros) |
$ |
A single $ is fixed; a run of $ floats next to the first digit |
IDENTIFICATION DIVISION.
PROGRAM-ID. EDITED.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-AMOUNT PIC S9(5)V99.
01 WS-PLAIN PIC ZZ,ZZ9.99.
01 WS-CHEQUE PIC $**,**9.99.
01 WS-FLOAT PIC $$$,$$9.99.
01 WS-LEDGER PIC ZZ,ZZ9.99CR.
01 WS-SIGNED PIC ---,--9.99.
PROCEDURE DIVISION.
MOVE -1234.5 TO WS-AMOUNT.
MOVE WS-AMOUNT TO WS-PLAIN WS-CHEQUE WS-FLOAT
WS-LEDGER WS-SIGNED.
DISPLAY "PLAIN [" WS-PLAIN "]".
DISPLAY "CHEQUE [" WS-CHEQUE "]".
DISPLAY "FLOAT [" WS-FLOAT "]".
DISPLAY "LEDGER [" WS-LEDGER "]".
DISPLAY "SIGNED [" WS-SIGNED "]".
STOP RUN.
PLAIN [ 1,234.50]
CHEQUE [$*1,234.50]
FLOAT [ $1,234.50]
LEDGER [ 1,234.50CR]
SIGNED [ -1,234.50]
Notice the 9 just before the decimal point in each picture. It forces at
least one digit, so zero prints as 0.00 rather than blanks. If every
digit position is Z, a zero value prints as all spaces, which is
sometimes exactly what a report wants.
Signs
An edited field without a sign symbol shows the absolute value: look at
PLAIN and CHEQUE above, where the minus has vanished. To show the sign:
| Symbol | Negative | Positive or zero |
|---|---|---|
CR at the end |
CR |
two spaces |
DB at the end |
DB |
two spaces |
- at either end |
- |
space |
+ at either end |
- |
+ |
Like $, a run of - or + floats: ---,--9.99 puts the minus right
next to the first digit. CR (credit) and DB (debit) are standard on
bank statements and ledgers.
Insertion characters
B inserts a space, 0 inserts a zero and / inserts a slash, wherever
they appear:
IDENTIFICATION DIVISION.
PROGRAM-ID. INSERTS.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-DATE PIC 9(8) VALUE 20260924.
01 WS-DATE-OUT PIC 9999/99/99.
01 WS-SORT-CODE PIC 9(6) VALUE 931152.
01 WS-SORT-OUT PIC 99B99B99.
01 WS-THOUSANDS PIC 9(3) VALUE 125.
01 WS-THOUS-OUT PIC 999000.
PROCEDURE DIVISION.
MOVE WS-DATE TO WS-DATE-OUT.
MOVE WS-SORT-CODE TO WS-SORT-OUT.
MOVE WS-THOUSANDS TO WS-THOUS-OUT.
DISPLAY "DATE [" WS-DATE-OUT "]".
DISPLAY "SORT CODE [" WS-SORT-OUT "]".
DISPLAY "THOUSANDS [" WS-THOUS-OUT "]".
STOP RUN.
DATE [2026/09/24]
SORT CODE [93 11 52]
THOUSANDS [125000]
Rules to remember
- An edited field is for output. It holds text, so you can't do arithmetic on it. Keep the real value in a numeric field.
- The edited field must have room for the largest value: count the digit
positions (
Z,9,*, and all but the first of a floating$,+or-). Too few and the leftmost digits are lost, just as with any numericMOVE. - Width is fixed.
ZZ,ZZ9.99is always nine characters, which is what keeps report columns lined up.
On the job
Nearly every report you maintain will use edited pictures. When a
total on a report has lost its first digit, the edited field is too
small for the value. That's a one-line fix in the DATA
DIVISION, but it has to be found first.
Your task
A payments program reads a date (YYYYMMDD) and an amount between
-99,999.99 and 99,999.99. Change the pictures of the four OUT- fields
so the output looks like this. Don't change the PROCEDURE DIVISION.
For 20260924 and -1234.5:
DATE: 2026/09/24
LEDGER: [ 1,234.50CR]
SIGNED: [ -1,234.50]
CHEQUE: [$*1,234.50]
For 20261101 and 7.05:
DATE: 2026/11/01
LEDGER: [ 7.05 ]
SIGNED: [ 7.05]
CHEQUE: [$*****7.05]
| Field | Format |
|---|---|
OUT-DATE |
slashes between year, month and day |
OUT-LEDGER |
zero-suppressed with a thousands comma, 2 decimals, CR when negative |
OUT-SIGNED |
a floating minus sign next to the first digit, thousands comma, 2 decimals |
OUT-CHEQUE |
fixed $, then * check protection with a thousands comma, 2 decimals |
Every format shows at least one digit before the decimal point.