This page showcases my COBOL project on mortgage analysis. Below, you will find a summary of the project along with the annotated COBOL source code.
Objective: By processing input data, applying payment schedules, and figuring out interest and principal breakdowns over time, the COBOL software computes loan amortization. After completing the required computations and reading the loan details from an input dataset, it outputs the findings to an output dataset. By connecting the COBOL source code to the required datasets and system libraries, the related JCL guarantees that the program compiles and runs properly. By enabling automatic financial computations, this configuration enables users to examine loan payback plans and the effect of early payments on interest savings.
Key Features:
Below is an excerpt of the mortgage analysis COBOL program with comments explaining its functionality.
LOANAM.CBL
IDENTIFICATION DIVISION.
PROGRAM-ID. LOANAM.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT LOAN-IN ASSIGN TO 'KC03B4F.LOANIN.DAT'
ORGANIZATION IS LINE SEQUENTIAL.
SELECT LOAN-OUT ASSIGN TO 'KC03B4F.LOANOUT.DAT'
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD LOAN-IN.
01 LOAN-RECORD.
05 LOAN-AMOUNT PIC 9(7)V99.
05 INTEREST-RATE PIC 9(2)V99.
05 TERM-MONTHS PIC 9(3).
FD LOAN-OUT.
01 PAYMENT-RECORD.
05 PAYMENT-NUM PIC 9(3).
05 PAYMENT-AMOUNT PIC 9(7)V99.
05 PRINCIPAL-PAID PIC 9(7)V99.
05 INTEREST-PAID PIC 9(7)V99.
05 REMAINING-BAL PIC 9(7)V99.
WORKING-STORAGE SECTION.
01 WS-MONTHLY-PAYMENT PIC 9(7)V99.
01 WS-INTEREST PIC 9(7)V99.
01 WS-PRINCIPAL PIC 9(7)V99.
01 WS-BALANCE PIC 9(7)V99.
01 WS-COUNTER PIC 9(3) VALUE 0.
PROCEDURE DIVISION.
MAIN-PROCESS.
OPEN INPUT LOAN-IN OUTPUT LOAN-OUT.
READ LOAN-IN AT END MOVE 0 TO WS-BALANCE.
MOVE LOAN-AMOUNT TO WS-BALANCE.
PERFORM CALCULATE-MONTHLY-PAYMENT.
PERFORM PROCESS-PAYMENTS UNTIL WS-BALANCE <= 0.
CLOSE LOAN-IN LOAN-OUT.
STOP RUN.
CALCULATE-MONTHLY-PAYMENT.
COMPUTE WS-MONTHLY-PAYMENT =
(LOAN-AMOUNT * (INTEREST-RATE / 1200)) /
(1 - (1 + (INTEREST-RATE / 1200)) ** (- TERM-MONTHS)).
PROCESS-PAYMENTS.
ADD 1 TO WS-COUNTER.
COMPUTE WS-INTEREST = (WS-BALANCE * INTEREST-RATE) / 1200.
COMPUTE WS-PRINCIPAL = WS-MONTHLY-PAYMENT - WS-INTEREST.
COMPUTE WS-BALANCE = WS-BALANCE - WS-PRINCIPAL.
WRITE PAYMENT-RECORD FROM
(WS-COUNTER, WS-MONTHLY-PAYMENT, WS-PRINCIPAL, WS-INTEREST, WS-BALANCE).
IDENTIFICATION DIVISION Declares the program name (LOANAM).
ENVIRONMENT DIVISION Defines file locations.
FILE SECTION Declares input (LOAN-IN) and output (LOAN-OUT) files.
WORKING-STORAGE SECTION Defines variables for loan calculations.
PROCEDURE DIVISION Contains logic for opening files, reading input, performing amortization calculations, and writing output.
LOANAM.JCL
//LOANAM JOB 1,NOTIFY=&SYSUID
//* Compile Step
//COBRUN EXEC IGYWCL
//COBOL.SYSIN DD DSN=&SYSUID..COBOL.CBL(LOANAM),DISP=SHR
//LKED.SYSLMOD DD DSN=&SYSUID..COBOL.LOAD(LOANAM),DISP=SHR
//* Conditional Execution
// IF RC = 0 THEN
//RUNLOAN EXEC PGM=LOANAM
//STEPLIB DD DSN=&SYSUID..COBOL.LOAD,DISP=SHR
//INPUT DD DSN=&SYSUID..LOANIN.DAT,DISP=SHR
//OUTPUT DD DSN=&SYSUID..LOANOUT.DAT,DISP=(MOD,CATLG),
// UNIT=SYSDA,
// SPACE=(TRK,(1,1))
//SYSOUT DD SYSOUT=*
//SYSERR DD SYSOUT=*
// ELSE
//SYSOUT DD SYSOUT=*,OUTLIM=15000
// ENDIF
JOB Statement (//LOANAM JOB) Starts the JCL job.
Compile Step (COBRUN EXEC IGYWCL) Compiles the COBOL program using a system procedure.
COBOL.SYSIN References the COBOL source code.
LKED.SYSLMOD Specifies the load module where the compiled program is stored.
Conditional Execution (IF RC = 0 THEN) Runs the program only if compilation succeeds.
Execution Step (RUNLOAN EXEC PGM=LOANAM) Runs the compiled COBOL program.
STEPLIB Points to the COBOL load library.
INPUT/OUTPUT Defines datasets for input (LOANIN.DAT) and output (LOANOUT.DAT).