This repo shows a real migration from COBOL batch processing to Java. The original ran on IBM MVS mainframes in the late 1980s. It processed weekly payroll for a manufacturing company — reading fixed-width employee records, calculating gross pay with overtime, applying tax codes, and printing a report to a sequential file.
PAYROLL.cob reads an 80-character fixed-width sequential file. Each record holds an employee ID, name, hourly rate, hours worked for the week, and a tax code (S=single, M=married, E=exempt). It calculates overtime at 1.5x for hours over 40, applies the tax rate, and writes a formatted report line. It's typical OS/VS COBOL — WORKING-STORAGE for all variables, FILE SECTION with FD entries, PERFORM loops instead of functions.
The Java version keeps the same business logic but uses modern constructs:
BigDecimalthroughout — COBOL's packed decimal arithmetic doesn't map cleanly todouble, so we useBigDecimalwithRoundingMode.HALF_UPto match the original's rounding behavior- Java records for
EmployeeandPayrollResult— immutable, no setter sprawl - The fixed-width parser uses the same byte offsets as the COBOL FD definition, so existing data files work without conversion
- Tax rates in a
Mapinstead of anEVALUATEblock — same logic, easier to extend
What we didn't change: the calculation logic itself. Same overtime threshold, same tax rate values, same rounding. The goal was a 1:1 functional replacement, not a redesign.
COBOL (requires GnuCOBOL):
cobc -x PAYROLL.cob -o payroll
./payrollJava (requires JDK 16+):
javac PayrollProcessor.java
java PayrollProcessor employees.datThe input file format is the same for both: 80-char fixed-width records matching the COBOL FD layout.
We do this for a living — COBOL, VB6, Fortran, Delphi to modern languages. codemigra.com