../courses.php
COBOL
COBOL102
3
COBOL Program Structure
COBOL programs are organized into divisions so purpose, data, files, and instructions are easier to find.
Why does COBOL use divisions?
COBOL uses divisions to organize a program into clear sections for identification, environment, data, and procedure instructions.
COBOL looks different from many modern languages.
Its structure is more formal.
That formality helps maintainers find what they need.
A COBOL program is commonly organized into named divisions.
The most important beginning idea is this: structure comes before instructions.
The main COBOL divisions
IDENTIFICATION DIVISION.
PROGRAM-ID. CUSTOMER-REPORT.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
DISPLAY "REPORT STARTING".
STOP RUN.
IDENTIFICATION DIVISION identifies the program.
ENVIRONMENT DIVISION can describe outside resources such as files.
DATA DIVISION describes the data the program uses.
PROCEDURE DIVISION contains the running instructions.
The divisions help readers understand where each kind of information belongs.
Order
Divisions give COBOL programs a predictable shape.
Maintenance
Readers can locate program purpose, data, and instructions.
Files
COBOL can separate file setup from processing logic.
Business systems
Long-running systems need code that can be found and changed carefully.
Everything mixed together
DISPLAY "REPORT"
01 CUSTOMER-NAME PIC X(30)
PROGRAM-ID. TEST
Organized by division
IDENTIFICATION DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
Ask ChatGPT: "Identify each COBOL division in this program and explain what belongs there."
Write the IDENTIFICATION DIVISION.
Add a PROGRAM-ID.
Add the DATA DIVISION.
Add the PROCEDURE DIVISION.
Explain why COBOL separates structure from instructions.
Putting instructions before the program structure.
Ignoring the DATA DIVISION.
Forgetting the PROCEDURE DIVISION.
Thinking divisions are decoration.
Trying to read COBOL without first finding the divisions.
Identify the main COBOL divisions and explain what each one is for.
Login - Jit4All
Login
Welcome back to Jit4All