DEV Community

Mecanik1337
Mecanik1337

Posted on

COBOL Database Migration Tool - VSAM, DB2, CICS, IMS to 5 Modern SQL Databases With DAL Code in 6 Languages

Good morning.

This is my next addition to the COBOL world.

A few weeks ago I posted about Easy COBOL Migrator, a desktop transpiler that converts COBOL to 6 modern languages. The most common question was: "What about the data layer?" Fair question. That's the part where migration projects actually stall and budgets explode. So I built the companion tool.

Easy COBOL DB Migrator analyzes COBOL data definitions and generates modern database schemas, data access layer code, and migration scripts. Desktop app, runs offline, no cloud, no AI.

What it parses

The tool detects 10 source system types automatically:

Flat files (sequential and line-sequential) from FD record layouts. All 5 VSAM types: KSDS (indexed with RECORD KEY), ESDS (entry-sequenced), RRDS (relative with RELATIVE KEY), VRRDS (variable-length relative), LDS (linear). DB2 embedded SQL with EXEC SQL blocks, host variable resolution against WORKING-STORAGE, cursor detection, DECLARE CURSOR parsing. CICS file operations: READ, WRITE, REWRITE, DELETE, STARTBR, READNEXT mapped to database equivalents. IMS/DL-I with CALL 'CBLTDLI' and EXEC DLI, function codes (GU, GN, GNP, ISRT, REPL, DLET), PCB mask structures and qualified SSAs.

What it generates

SQL DDL for PostgreSQL, MySQL, SQL Server, Oracle and SQLite with correct dialect. Each database gets proper auto-increment syntax (SERIAL vs AUTO_INCREMENT vs IDENTITY vs sequence), identifier quoting, type mappings and constraint definitions.

Data access layer code in Java, C#, Python, C++, Rust and Go. Each language gets entity/model classes and repository/DAO classes with full CRUD (create, findById, findAll, update, delete). Java gets BigDecimal and JDBC PreparedStatement. C# gets decimal and ADO.NET. Python gets dataclass with Decimal and DB-API 2.0. C++ gets struct with std::optional and ODBC. Rust gets struct with derive macros and sqlx patterns. Go gets struct with db tags and database/sql.

Migration/ETL scripts with database-specific bulk load commands: COPY for PostgreSQL, LOAD DATA for MySQL, BULK INSERT for SQL Server, SQL*Loader for Oracle, .import for SQLite. Plus validation queries for row counts and constraint verification.

HTML migration report with field-level type mapping rationale, migration issues by severity, and access pattern documentation.

CSV mapping exports and interactive ER diagrams exportable as PNG/SVG.

The type mapping engine

Every PIC/USAGE combination maps correctly per database:

PIC S9(7)V99 COMP-3 becomes NUMERIC(9,2) in PostgreSQL, DECIMAL(9,2) in MySQL/SQL Server, NUMBER(9,2) in Oracle.

PIC X(30) becomes VARCHAR(30). Short alphanumerics (10 chars or less) use CHAR to preserve COBOL fixed-width semantics. Longer fields use VARCHAR.

Level 88 conditions become CHECK constraints or BOOLEAN columns. Two values ("Y"/"N") generate BOOLEAN. Multiple enumerated values generate CHECK (or ENUM in MySQL).

OCCURS arrays normalize to child tables with foreign keys and a seq_num column. FILLER fields are skipped. REDEFINES uses the primary definition and documents the alternative.

IMS hierarchy flattening

IMS segments become relational tables with foreign keys:

IMS:                          SQL:
POLICY (root)            ->   policy (PK: policy_key)
  +-- CLAIMANT           ->   claimant (FK -> policy)
  |     +-- CLAIM        ->   claim (FK -> claimant)
  |           +-- PAYMENT ->  payment (FK -> claim)
  +-- COVERAGE           ->   coverage (FK -> policy)
Enter fullscreen mode Exit fullscreen mode

DL/I function codes map to SQL: GU becomes SELECT WHERE, GN becomes cursor FETCH, ISRT becomes INSERT, REPL becomes UPDATE, DLET becomes DELETE.

Enterprise: actual data extraction

The Enterprise edition reads real COBOL data files and handles EBCDIC-to-ASCII conversion (CP037), COMP-3 packed decimal unpacking, binary field parsing, zoned decimal sign handling, and implied decimal insertion. Exports as batched SQL INSERT statements or CSV.

How both tools work together

  1. Run Easy COBOL Migrator. Get converted code with TODO markers where EXEC SQL/CICS/DLI blocks were.
  2. Run Easy COBOL DB Migrator on the same source. Get database schema, data access code, and migration scripts.
  3. Replace the TODO markers with generated repository/DAO code.
  4. Run validation queries to verify data migration.

Free demo: PostgreSQL + C++, up to 3 source files.

👉 Free demo download

Desktop app, Qt/C++, Windows/macOS/Linux. Everything offline. This is how I spend my free time apparently.

If you've got COBOL with VSAM files, DB2 queries or IMS databases, throw it at the demo. I want to know what breaks.

Top comments (0)