IDENTIFICATION DIVISION.
PROGRAM-ID. EMPLOYEE-DB-APP.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT EMPLOYEE-DB ASSIGN TO “employee-db.dat” ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD EMPLOYEE-DB.
01 EMPLOYEE-RECORD.
05 EMP-ID PIC X(10).
05 EMP-LASTNAME PIC X(20).
05 EMP-FIRSTNAME PIC X(20).
05 EMP-INITIAL PIC X(1).
05 EMP-DOB PIC X(10).
05 EMP-ADDRESS PIC X(30).
05 EMP-PHONE PIC X(20).
05 EMP-EMAIL PIC X(30).
WORKING-STORAGE SECTION.
01 WS-OPTION PIC X.
01 WS-EMPLOYEE PIC X(10).
01 WS-FOUND-FLAG PIC X.
PROCEDURE DIVISION.
MAIN-MENU.
DISPLAY “EMPLOYEE DATABASE MANAGEMENT SYSTEM”.
DISPLAY “1. ADD RECORD”.
DISPLAY “2. DELETE RECORD”.
DISPLAY “3. CHANGE RECORD”.
DISPLAY “4. PRINT RECORD”.
DISPLAY “5. EXIT”.
ACCEPT WS-OPTION.
IF WS-OPTION = '1'
PERFORM ADD-RECORD
ELSE IF WS-OPTION = '2'
PERFORM DELETE-RECORD
ELSE IF WS-OPTION = '3'
PERFORM CHANGE-RECORD
ELSE IF WS-OPTION = '4'
PERFORM PRINT-RECORD
ELSE IF WS-OPTION = '5'
STOP RUN.
ELSE
DISPLAY “INVALID OPTION”.
PERFORM MAIN-MENU.
END-IF.
ADD-RECORD.
DISPLAY “ENTER EMPLOYEE ID”.
ACCEPT EMP-ID.
DISPLAY “ENTER EMPLOYEE LAST NAME”.
ACCEPT EMP-LASTNAME.
DISPLAY “ENTER EMPLOYEE FIRST NAME”.
ACCEPT EMP-FIRSTNAME.
DISPLAY “ENTER EMPLOYEE INITIAL”.
ACCEPT EMP-INITIAL.
DISPLAY “ENTER EMPLOYEE DATE OF BIRTH”.
ACCEPT EMP-DOB.
DISPLAY “ENTER EMPLOYEE ADDRESS”.
ACCEPT EMP-ADDRESS.
DISPLAY “ENTER EMPLOYEE PHONE NUMBER”.
ACCEPT EMP-PHONE.
DISPLAY “ENTER EMPLOYEE EMAIL”.
ACCEPT EMP-EMAIL.
OPEN OUTPUT EMPLOYEE-DB.
WRITE EMPLOYEE-RECORD.
CLOSE EMPLOYEE-DB.
DISPLAY “RECORD ADDED SUCCESSFULLY”.
PERFORM MAIN-MENU.
DELETE-RECORD.
DISPLAY “ENTER EMPLOYEE ID TO BE DELETED”.
ACCEPT WS-EMPLOYEE.
OPEN INPUT EMPLOYEE-DB.
READ EMPLOYEE-DB.
IF EMP-ID = WS-EMPLOYEE
DELETE EMPLOYEE-DB
DISPLAY “RECORD DELETED SUCCESSFULLY”.
ELSE
WS-FOUND-FLAG = 'N'.
END-IF.
CLOSE EMPLOYEE-DB.
IF WS-FOUND-FLAG = 'N'
DISPLAY “RECORD NOT FOUND”.
END-IF.
PERFORM MAIN-MENU.
CHANGE-RECORD.
DISPLAY “ENTER EMPLOYEE ID TO BE CHANGED”.
ACCEPT WS-EMPLOYEE.
OPEN INPUT EMPLOYEE-DB.
READ EMPLOYEE-DB.
IF EMP-ID = WS-EMPLOYEE
PERFORM CHANGE-INPUT
ELSE
WS-FOUND-FLAG = 'N'.
END-IF.
CLOSE EMPLOYEE-DB.
IF WS-FOUND-FLAG = 'N'
DISPLAY “RECORD NOT FOUND”.
END-IF.
PERFORM MAIN-MENU.
CHANGE-INPUT.
DISPLAY “ENTER NEW EMPLOYEE LAST NAME”.
ACCEPT EMP-LASTNAME.
DISPLAY “ENTER NEW EMPLOYEE FIRST NAME”.
ACCEPT EMP-FIRSTNAME.
DISPLAY “ENTER NEW EMPLOYEE INITIAL”.
ACCEPT EMP-INITIAL.
DISPLAY “ENTER NEW EMPLOYEE DATE OF BIRTH”.
ACCEPT EMP-DOB.
DISPLAY “ENTER NEW EMPLOYEE ADDRESS”.
ACCEPT EMP-ADDRESS.
DISPLAY “ENTER NEW EMPLOYEE PHONE NUMBER”.
ACCEPT EMP-PHONE.
DISPLAY “ENTER NEW EMPLOYEE EMAIL”.
ACCEPT EMP-EMAIL.
OPEN OUTPUT EMPLOYEE-DB.
WRITE EMPLOYEE-RECORD.
CLOSE EMPLOYEE-DB.
DISPLAY “RECORD CHANGED SUCCESSFULLY”.
PERFORM MAIN-MENU.
PRINT-RECORD.
DISPLAY “ENTER EMPLOYEE ID TO BE PRINTED”.
ACCEPT WS-EMPLOYEE.
OPEN INPUT EMPLOYEE-DB.
READ EMPLOYEE-DB.
IF EMP-ID = WS-EMPLOYEE
DISPLAY EMPLOYEE-RECORD.
ELSE
WS-FOUND-FLAG = 'N'.
END-IF.
CLOSE EMPLOYEE-DB.
IF WS-FOUND-FLAG = 'N'
DISPLAY “RECORD NOT FOUND”.
END-IF.
PERFORM MAIN-MENU.
STOP RUN.