COBOL PIC Clauses Explained: 9, X, A, S, V and Editing Symbols
A COBOL PICTURE clause sets a field's size and type. Learn the symbols 9, X, A, S and V and the editing symbols Z, comma, point, dollar, star and CR.

Every variable in a COBOL program has a PICTURE clause, written PIC, and it is the first thing a newcomer has to learn. It is a short pattern that says how many characters a field holds, whether they are digits or letters, where an implied decimal point sits, whether the number has a sign and how it should look when it is printed. This post goes through the symbols you will meet most, using Enterprise COBOL for z/OS 6.4, with the result of each move and display worked out so you can check your own reading. It assumes nothing: each symbol is defined as it is used. It follows the post on the four divisions and comes before the work on numeric usage.
The basic idea
A picture is a string of symbols. Each symbol is one character position. A repeat count in brackets saves typing: PIC X(10) is the same as PIC XXXXXXXXXX. There are three families:
| Family | Symbols | Used for |
|---|---|---|
| Alphanumeric | X, A, 9 | Text and codes |
| Numeric | 9, S, V, P | Numbers that programs calculate with |
| Numeric edited and alphanumeric edited | Z, *, $, ,, ., +, -, CR, DB, B, 0, / | Output formatting |
Fields for calculation use plain numeric pictures. Fields for display or printing use edited pictures. A common mistake is to calculate with an edited field, which the compiler does not allow as a source of arithmetic.
The core symbols
X holds any character. PIC X(5) holds five characters, and when you move a shorter value into it, the value is placed at the left and the rest is filled with spaces. A longer value is cut on the right.
A holds only letters and spaces. It is rarely used, because X is more flexible, and the compiler does not check the content at run time on its own.
9 holds one decimal digit. PIC 9(5) holds five digits, and VALUE 42 stores 00042. A numeric field is stored as characters, one digit per byte, in the default usage called DISPLAY. Other usages that store numbers in binary or packed form are the subject of a later post.
S makes the field signed. It takes no space of its own: the sign is stored in the last digit, as an overpunch. A signed field, PIC S9(3), with the value -125 is stored as three bytes where the last byte is not the character 5 but a different character that combines the digit 5 with a negative sign. If you DISPLAY such a field, the last character looks odd, for example 12N. The compiler displays the sign this way, so never print a signed field directly: move it to an edited field first.
V is an implied decimal point. It takes no space either. PIC 9(3)V99 holds five digits and the program treats the last two as decimals. The value 25.50 is stored as 02550. If you move it to an edited field with a printed point, the point appears in the right place. If you display the raw field, you will see 02550 with no point.
P is a scaling position for numbers that are very large or very small, and it is seldom used.
Examples of numeric moves
Assume these declarations:
IDENTIFICATION DIVISION.
PROGRAM-ID. PICDEMO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-COUNT PIC 9(5).
01 WS-PRICE PIC 9(3)V99.
01 WS-TEXT PIC X(8).
01 WS-SHORT PIC 99.
PROCEDURE DIVISION.
MOVE 42 TO WS-COUNT
MOVE 25.5 TO WS-PRICE
MOVE 'COBOL' TO WS-TEXT
MOVE 12345 TO WS-SHORT
DISPLAY 'COUNT=' WS-COUNT
DISPLAY 'PRICE=' WS-PRICE
DISPLAY 'TEXT=[' WS-TEXT ']'
DISPLAY 'SHORT=' WS-SHORT
GOBACK.COUNT=00042
PRICE=02550
TEXT=[COBOL ]
SHORT=45The count is padded with zeros on the left. The price keeps its implied point out of the stored digits. The text is padded with spaces on the right. The last move puts a five-digit number into a two-digit field. A numeric move aligns on the decimal point and drops the digits that do not fit on the high-order side, so only 45 is left. This truncation is silent and is a common source of wrong totals.
Editing symbols
An edited picture changes how a value looks. These are the symbols and what each does:
| Symbol | Effect |
|---|---|
Z | Replaces a leading zero with a space |
* | Replaces a leading zero with an asterisk, as on a cheque |
$ | Inserts a currency sign. Several in a row make it float next to the first digit |
, and . | Insert a comma or a point in the position shown |
+ and - | Show the sign. A minus appears only for a negative value, a plus appears for both signs |
CR and DB | Print as a suffix when the value is negative, and as spaces when positive |
B | Inserts a space |
0 | Inserts a zero |
/ | Inserts a slash |
The result of moving a value into an edited field follows a few rules. The value is aligned on the decimal point. Zero suppression, the work of Z and *, stops at the first nonzero digit or at a 9 in the picture. Insertion characters such as the comma are shown only if a digit before them is shown.
Here are worked results for moving 1234.50 into several pictures. The right-hand column is exactly what is stored:
| Picture | Result |
|---|---|
ZZ,ZZ9.99 | 1,234.50 |
$$,$$9.99 | $1,234.50 |
***,**9.99 | **1,234.50 |
9(5).99 | 01234.50 |
The first row has a leading space, because the first Z position holds a zero that is suppressed. The second row floats the dollar sign next to the first digit. The third row fills the leading positions with stars.
For a negative value, -5.5 moved to PIC 999.99CR, the result is 005.50CR, and for PIC 999.99- it is 005.50-. For a positive value, the CR position becomes spaces.
An insertion example for a date held as digits: PIC 99/99/99 with the value 231123 gives 23/11/23.
Using an edited field
IDENTIFICATION DIVISION.
PROGRAM-ID. EDITED.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-AMOUNT PIC S9(5)V99 VALUE 1234.50.
01 WS-PRINT PIC ZZ,ZZ9.99-.
PROCEDURE DIVISION.
MOVE WS-AMOUNT TO WS-PRINT
DISPLAY 'AMOUNT:' WS-PRINT
COMPUTE WS-AMOUNT = WS-AMOUNT * -1
MOVE WS-AMOUNT TO WS-PRINT
DISPLAY 'AMOUNT:' WS-PRINT
GOBACK.AMOUNT: 1,234.50
AMOUNT: 1,234.50-The picture has a trailing minus that shows for negative values and is a space otherwise, so the first line ends with a space. Moving a numeric field to an edited field is how you prepare it for a report line.
Rules worth remembering
The size of the field is the count of character positions, except that S, V and P take none. So PIC S9(3)V99 is five bytes in the default usage. An edited picture takes a position for every symbol including the comma and the point.
A numeric picture holds at most 18 digits in Enterprise COBOL 6.4 with the default ARITH(COMPAT) option, and up to 31 digits with ARITH(EXTEND). Check the setting for your site before you declare a very long number.
Do not do arithmetic on an edited field and do not move an alphanumeric field with letters in it to a numeric field, since the result is unpredictable and a later arithmetic statement may end with a data exception abend.
The picture symbols are in the Language Reference of the Enterprise COBOL for z/OS documentation, under the PICTURE clause.


