Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Read a file of customer records and display each record.
IDENTIFICATION DIVISION.
PROGRAM-ID. READ-CUSTOMERS.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CUSTOMER-FILE ASSIGN TO 'CUSTOMERS.DAT'
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD CUSTOMER-FILE.
01 CUSTOMER-REC.
05 CUST-ID PIC 9(5).
05 CUST-NAME PIC A(20).
WORKING-STORAGE SECTION.
01 EOF-FLAG PIC X VALUE 'N'.
PROCEDURE DIVISION.
OPEN INPUT CUSTOMER-FILE.
READ-CUSTOMER.
PERFORM UNTIL EOF-FLAG = 'Y'
DISPLAY 'ID: ' CUST-ID ' Name: ' CUST-NAME
READ CUSTOMER-FILE AT END MOVE 'Y' TO EOF-FLAG
END-PERFORM.
CLOSE CUSTOMER-FILE.
STOP RUN.COBOL Variants refer to the different dialects and implementations of COBOL (Common Business-Oriented Language), a legacy programming language widely used in business, finance, and administrative systems.
Origin & Creator
Developed in 1959 by a consortium including CODASYL and led by Grace Hopper to provide a standardized business programming language.
Industrial Note
Extensively used in banking, insurance, government payroll systems, and mainframe applications where decades-old COBOL systems still operate mission-critical workloads.