Complete Guide with Examples
COBOL (Common Business-Oriented Language) is one of the most important programming languages in the mainframe world. This beginner guide explains COBOL fundamentals, program structure and syntax.
It is one of the oldest and most reliable programming languages in the world. Despite being developed in 1959, COBOL continues to power critical business applications in banking, insurance, healthcare, government, and large enterprises.
Many of the world's largest financial institutions still process millions of transactions daily using COBOL applications running on IBM Mainframes.
In this beginner-friendly tutorial, you'll learn the basics of COBOL, its structure, and how to write your first COBOL program.
What is COBOL?
COBOL stands for:
COmmon Business-Oriented Language
It was designed specifically for:
Business applications
Financial systems
Payroll processing
Banking transactions
Insurance systems
Why is COBOL Still Important?
High reliability
Excellent performance
Handles massive transaction volumes
Used by major banks and government organizations
Strong demand for Mainframe professionals
COBOL Program Structure
A COBOL program is divided into four major divisions:
Identification Division
Environment Division
Data Division
Procedure Division
Basic Structure
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
DISPLAY "HELLO WORLD".
STOP RUN.
Understanding Each Division
1. Identification Division
Provides program information.
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO.
Purpose
Program name
Documentation
Program identification
2. Environment Division
Defines system-related information.
ENVIRONMENT DIVISION.
Examples:
Input files
Output files
Device configurations
For simple programs, this division may remain empty.
3. Data Division
Defines variables and data structures.
Example:
DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NAME PIC X(20). 01 WS-AGE PIC 99.
Explanation
| Statement | Meaning |
|---|---|
| PIC X(20) | Character field of 20 characters |
| PIC 99 | Numeric field with 2 digits |
4. Procedure Division
Contains executable logic.
PROCEDURE DIVISION.
DISPLAY "WELCOME TO COBOL".
STOP RUN.
Your First COBOL Program
IDENTIFICATION DIVISION.
PROGRAM-ID. FIRSTPROG.
PROCEDURE DIVISION.
DISPLAY "WELCOME TO COBOL PROGRAMMING".
STOP RUN.
Output
WELCOME TO COBOL PROGRAMMING
Working with Variables
Example:
IDENTIFICATION DIVISION.
PROGRAM-ID. EMPLOYEE.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NAME PIC X(20).
PROCEDURE DIVISION.
MOVE "PUNIT" TO WS-NAME
DISPLAY "EMPLOYEE NAME: " WS-NAME
STOP RUN.
Output
EMPLOYEE NAME: PUNIT
Performing Calculations
Example:
IDENTIFICATION DIVISION.
PROGRAM-ID. ADDITION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 NUM1 PIC 999 VALUE 100.
01 NUM2 PIC 999 VALUE 200.
01 RESULT PIC 999.
PROCEDURE DIVISION.
ADD NUM1 TO NUM2 GIVING RESULT
DISPLAY "TOTAL = " RESULT
STOP RUN.
Output
TOTAL = 300
IF Condition Example
Example:
IDENTIFICATION DIVISION.
PROGRAM-ID. RESULT.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 MARKS PIC 999 VALUE 75.
PROCEDURE DIVISION.
IF MARKS >= 50
DISPLAY "PASS"
ELSE
DISPLAY "FAIL"
END-IF
STOP RUN.
Output
PASS
Loop Example (PERFORM)
Example:
IDENTIFICATION DIVISION.
PROGRAM-ID. LOOPTEST.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-COUNT PIC 9 VALUE 1.
PROCEDURE DIVISION.
PERFORM UNTIL WS-COUNT > 5
DISPLAY "COUNT = " WS-COUNT
ADD 1 TO WS-COUNT
END-PERFORM
STOP RUN.
Output
COUNT = 1 COUNT = 2 COUNT = 3 COUNT = 4 COUNT = 5
COBOL Data Types
Alphanumeric
PIC X(10)
Example:
PUNIT
Numeric
PIC 999
Example:
123
Decimal
PIC 999V99
Example:
123.45
Common COBOL Verbs
| Verb | Purpose |
|---|---|
| MOVE | Assign value |
| ADD | Addition |
| SUBTRACT | Subtraction |
| MULTIPLY | Multiplication |
| DIVIDE | Division |
| DISPLAY | Print output |
| ACCEPT | Read input |
| PERFORM | Loop/Call paragraph |
| IF | Conditional logic |
Real-World COBOL Applications
Banking
Account processing
ATM transactions
Loan systems
Insurance
Policy management
Claims processing
Retail
Billing systems
Inventory management
Government
Tax processing
Pension systems
Tips for Beginners
Learn COBOL syntax thoroughly.
Practice simple programs daily.
Understand JCL alongside COBOL.
Learn DB2 basics for database access.
Explore CICS for online transactions.
Study real-world Mainframe applications.
Frequently Asked Questions
Is COBOL still used today?
Yes. Many large organizations continue to rely on COBOL for mission-critical systems.
Is COBOL easy to learn?
Yes. COBOL's syntax is close to English and is considered beginner-friendly.
What should I learn after COBOL?
A recommended Mainframe learning path:
COBOL
JCL
VSAM
DB2
CICS
Mainframe Production Support
Conclusion
COBOL remains one of the most important programming languages in enterprise computing. By learning COBOL, you open opportunities in banking, insurance, government, and Mainframe development.
Start with basic programs, practice regularly, and gradually expand your knowledge into JCL, DB2, and CICS to build a strong Mainframe career.