Algonquin College · Summer 2025 Compiled with GnuCOBOL (
cobc) on Windows.
A collection of COBOL programs written for CST8283 Business Programming, covering sequential and indexed file I/O, internal table handling, multi-file reporting, and modular program design via COPY and CALL.
- Lab 4 — Stock Recommendation System
- Project 1 — Employee Records Manager
- Project 2 — Investment Portfolio Report
- PA3 — Indexed File CRUD (Skills-Based Assessment)
- Project 3 — Full Portfolio Management Suite
- Skills Demonstrated
- Build & Run
File: LAB4.cbl
An interactive console program that loads a stock file into an internal table (up to 20 entries) and lets the user query stocks by analyst recommendation rating.
Key features:
- Loads
STOCKS.TXTinto a 20-elementOCCURStable at startup - Validates analyst recommendation codes (1–4); silently skips records with invalid codes (5–9) using
88-level condition names - User enters a recommendation label (
STRONG BUY,BUY,HOLD,SELL, orQUIT) — input is validated in aPERFORM UNTILloop before any search runs - Searches the table with a
PERFORM VARYINGloop and displays all matching stock names and closing prices - Prints a run summary (records searched vs. records displayed) after each query
- Loops until the user enters
QUIT
Concepts: internal tables (OCCURS), 88-level condition names, EVALUATE TRUE, sequential file I/O, input validation loop.
File: PROJECT1.cbl
A standalone interactive program for creating and reviewing employee records stored in a flat sequential file.
Key features:
- Prompts the user whether to add a record before each entry — input validated with
88-level flags (INPUT-YES,INPUT-NO,INPUT-SPACE) - Collects six fields per employee: ID (6 digits), Department ID (3 digits), first/last name (20 chars each), and service years (formatted
99.9) - Writes records to
EMPLOYEES.TXTviaOPEN OUTPUT, then re-opens asOPEN INPUTto read back and display all records in a formatted tabular report - Uses
STRING ... INTOto build column headers at runtime - Handles the empty-file edge case with a guard counter (
RECORD-CTL)
Concepts: sequential flat-file I/O (write then read-back), formatted DISPLAY output, input validation, STRING verb.
File: PROJECT2.cbl
A batch reporting program that joins two input files and writes a formatted financial report to a third file.
Key features:
- Loads up to 20 stock records from
STOCKS.TXTinto anOCCURStable at initialisation - For each record in
PORTFOLIO.TXT, performs an in-memory table lookup by stock symbol (PERFORM VARYING ... UNTIL STOCK-FOUND) - Computes three derived fields per holding: cost base (
avg cost × shares), market value (closing price × shares), and gain/loss (signed,S9) - Writes a neatly formatted report to
REPORT.TXTusing picture editing characters ($$,$$$,$$9.99,$$,$$$,$$9.99-) — no post-processing needed - Footer line reports total records read and written
Concepts: multi-file I/O (two inputs + one output), internal table lookup, arithmetic verbs (MULTIPLY, SUBTRACT), signed numeric fields, picture-edit formatting.
Directory: PA3/ (inside PA3.zip)
Three programs working together on the same ISAM indexed file (IPROD.DAT), demonstrating full indexed file lifecycle management.
| Program | Purpose |
|---|---|
icreate.COB |
Loads PROD.TXT into a new indexed file (ORGANIZATION IS INDEXED, sequential access). Provided starter. |
iread.COB |
Reads and displays all records from the indexed file sequentially. Provided starter. |
starter3.COB |
Processes a transaction file (TRANS.TXT) and performs ADD / UPDATE / DELETE operations on the indexed file using RANDOM access mode. |
starter3.COB highlights:
- Opens the indexed file with
ACCESS MODE IS RANDOM(I-O) - Reads each transaction record and branches on the
CMDfield (ADD,UPD,DEL) usingEVALUATE TRUEwith88-level condition names - ADD:
WRITEwithINVALID KEYduplicate detection - UPDATE:
READby key, thenREWRITEwithINVALID KEYhandling - DELETE:
READby key, thenDELETE ... RECORDwithINVALID KEYhandling - All operations print a success or failure message; invalid command codes are caught and reported
Concepts: ISAM indexed file organisation, RANDOM access, WRITE/READ/REWRITE/DELETE verbs, file status codes (FILE STATUS IS), transaction-driven processing.
Directory: Project3_V1/ (inside Project3.zip)
A four-module COBOL system that covers the full lifecycle of an investment portfolio, from file conversion through interactive management to financial reporting.
Reads the flat PORTFOLIO.TXT and writes it to PORTFOLIO-INDEXED.DAT as an ISAM indexed file keyed on stock symbol. Handles duplicate-key errors and tracks records written.
A full-featured interactive menu system for managing the indexed portfolio file. Operates with ACCESS MODE IS DYNAMIC, enabling both sequential and random access in the same open file.
Menu operations:
- Add a new holding (validates that the stock symbol exists in
STOCKS.TXTbefore writing) - Update shares and average cost for an existing holding
- Delete a holding by stock symbol
- Display a single record by key
- List all holdings sequentially
- Quit with a session summary (records added, updated, deleted)
Each operation uses INVALID KEY / NOT INVALID KEY branching and reports the outcome to the user.
Generates the investment report by reading the indexed portfolio file sequentially and matching against the stocks table (loaded from STOCKS.TXT). Demonstrates two modularity techniques:
COPY COPYSTOCKS.txt— imports the stocks table data definition from an external copybookCALL 'P3C2'— delegates financial calculations to the subroutine below, passing arguments by reference via theLINKAGE SECTION
Writes a formatted report to REPORT.TXT with columns for shares, unit cost, closing price, cost base, market value, and signed gain/loss.
A called subprogram (compiled to P3C2.dll) that receives five numeric arguments via LINKAGE SECTION and computes:
Cost Base = Avg Cost × Shares
Market Value = Closing Price × Shares
Gain / Loss = Market Value − Cost Base
Returns control to the calling program with EXIT PROGRAM.
Concepts: indexed file conversion, DYNAMIC access mode, full CRUD on ISAM, COPY copybooks, CALL/EXIT PROGRAM subprogram linkage, LINKAGE SECTION, signed arithmetic.
| Area | Detail |
|---|---|
| File organisation | Sequential (LINE SEQUENTIAL), Indexed (ISAM) |
| Access modes | Sequential, Random, Dynamic |
| CRUD verbs | WRITE, READ, REWRITE, DELETE, INVALID KEY handling |
| Data structures | OCCURS tables, 88-level condition names, signed numeric PIC |
| Modularity | COPY copybooks, CALL/EXIT PROGRAM subprograms, LINKAGE SECTION |
| Report writing | Multi-file batch joins, picture-edit formatting, header/footer generation |
| User interaction | Input validation loops, menu-driven programs, EVALUATE TRUE dispatch |
| Error handling | File status codes, invalid-key guards, empty-file detection |
All programs were compiled with GnuCOBOL (cobc).
# Compile a standalone program
cobc -x -free LAB4.cbl -o LAB4
# Compile main program + subroutine (Project 3 C)
cobc -c -free P3C2.cbl # compile subroutine to object
cobc -x -free P3C1.cbl P3C2.o -o P3C1
# Run
./LAB4Input data files (STOCKS.TXT, PORTFOLIO.TXT, EMPLOYEES.TXT, etc.) are expected one directory level above the executable (../), matching the ASSIGN TO paths in each program.