COBOL Tutorial

Progress0 of 0 lessons

COBOL PIC

PIC is the standard abbreviation for PICTURE. Both keywords define the format of a data item in the Data Division: its length, type (numeric, alphanumeric, alphabetic), decimal position, sign, and for edited fields how the value is displayed. PIC and PICTURE are interchangeable; for the full set of picture characters and examples see PICTURE clause.

PIC vs PICTURE

There is no difference. PIC and PICTURE are the same clause. The COBOL standard allows the abbreviated form PIC; most programmers use PIC for brevity. The compiler treats both identically.

cobol
1
2
3
4
5
WORKING-STORAGE SECTION. 01 WS-NAME PIC X(30). 01 WS-AMOUNT PICTURE 9(7)V99. 01 WS-CODE PIC A(5). *> PIC and PICTURE are the same

Where PIC is used

PIC (or PICTURE) appears in the Data Division on data description entries. It follows the level number and optional data name. It defines how the item is stored and, for edited pictures, how it is displayed (e.g. with commas, dollar sign, or suppressed leading zeros).

Common examples

PIC / PICTURE examples
ClauseMeaning
PIC X(20)20-character alphanumeric field
PIC 9(5)V99Numeric with 5 integer and 2 decimal places
PICTURE A(10)10-character alphabetic (letters and space)
PIC S9(4)Signed 4-digit integer

The characters inside the clause (9, X, A, V, S, Z, $, etc.) define the format. For a full list and explanation of each character see the PICTURE clause quick reference.

Explain like I'm five

PIC (or PICTURE) is the “shape” of a box: “this box holds 20 letters and numbers” or “this box holds a number with two digits after the dot.” Same shape whether you say PICTURE or PIC.

Test Your Knowledge

1. What does PIC stand for in COBOL?

  • Program Instruction Code
  • Picture
  • Pointer Index Character
  • Process Input Control

2. Are PIC and PICTURE interchangeable?

  • No, PIC is newer
  • Yes, they mean the same thing
  • Only in free format
  • Only for numeric fields

Related Concepts

Related Pages