../courses.php
COBOL
COBOL104
3
Picture Clauses
The PIC clause tells COBOL exactly what kind of data a variable can store.
What is a PIC clause?
A PIC clause describes the size and type of data stored in a COBOL variable.
COBOL does not guess what data looks like.
Every important variable has a picture clause.
The picture describes the expected format.
Letters and numbers usually have different picture clauses.
This makes business data predictable.
Picture clauses
01 CUSTOMER-NAME PIC X(30).
01 CUSTOMER-AGE PIC 999.
01 ACCOUNT-BALANCE PIC 99999.
PIC introduces the picture clause.
X means character data.
9 means numeric data.
The repeated symbols describe maximum size.
COBOL uses these definitions throughout the program.
Accuracy
Business data needs clear definitions.
Validation
The expected format is obvious.
Maintenance
Future programmers know what belongs in each variable.
Consistency
Programs process data more reliably.
No data description
Complete definition
01 CUSTOMER-NAME PIC X(30).
Ask ChatGPT: "Explain what each PIC clause allows this COBOL variable to store."
Create one text variable.
Create one numeric variable.
Explain X.
Explain 9.
Explain why PIC clauses exist.
Using the wrong PIC clause.
Ignoring variable sizes.
Treating text like numbers.
Skipping the PIC clause.
Guessing data formats.
Read and write simple COBOL picture clauses.
Login - Jit4All
Login
Welcome back to Jit4All