PICTURE clause
The COBOL declaration that says what kind of data a field holds and how long it is, written as PIC.
Also written PIC, picture
The picture clause, almost always abbreviated PIC, defines a field's type and size. It is the most distinctive piece of COBOL syntax and the one to learn first.
The notation is compact. X means any character, so a field of X repeated thirty times holds thirty characters of text. The number 9 means a numeric digit. S marks a field as signed, so it can hold negatives. V marks an implied decimal point, which occupies no storage but tells the program where the decimal sits. Repetition is written in brackets rather than spelled out, so a long field is declared briefly.
There are also editing pictures used for output. These insert commas, decimal points, currency symbols, and turn leading zeros into spaces, so a stored number can be printed in a readable form without any formatting code.
The precision matters. Because COBOL knows the exact size and decimal placement of every numeric field, arithmetic on money behaves predictably, a guarantee that is much harder to get from languages using floating point.
Related terms
- DATA DIVISIONThe part of a COBOL program that declares every record layout and variable it will use.
- WORKING-STORAGEThe section of a COBOL program that declares its internal variables: counters, totals, flags and work areas.
- Packed decimalA compact way of storing numbers, two digits per byte, used heavily for amounts in business records.
- Level numberThe two-digit number in front of a COBOL data item that shows how fields nest inside a record.
- COBOLThe programming language most business logic on the mainframe is written in. Verbose by design, and still running the world's payments.