Understand your legacy COBOL code

Understand your legacy COBOL projects with AI-powered documentation. Transform complex, decades-old COBOL code into clear, actionable insights that empower your team to maintain and modernize mission-critical systems.

Legacy COBOL Code Documentation

Automated Code Analysis

Parse complex COBOL code to generate clear, structured documentation.

Business Logic Extraction

Uncover and document the core business rules hidden in your legacy COBOL code.

Continuous Documentation

Keep your documentation up-to-date as your legacy COBOL systems evolve.
Get Started ✨

Features

Discover how DocuWriter.ai helps you understand and document your legacy COBOL projects through advanced AI-driven capabilities.

Automated Analysis

Parse & Visualize COBOL Code

Our AI engine analyzes complex COBOL code and generates clear, structured documentation that reveals the inner workings of your legacy systems.

Business Logic Extraction

Understand What Your Code Does

Automatically extract and document the core business rules embedded in your COBOL code, making it easier to maintain and modernize your legacy projects.

Continuous Updates

Live Documentation

As your legacy COBOL projects evolve, our platform keeps your documentation accurate and up-to-date, ensuring seamless transitions and continuous clarity.

See the Transformation: From COBOL Code to Clear Documentation

Raw COBOL Code

IDENTIFICATION DIVISION.
PROGRAM-ID. PAYROLL.
AUTHOR. ChatGPT.
DATE-WRITTEN. 2025-02-07.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
    SELECT EMP-IN ASSIGN TO 'EMPLOYEE.DAT'
        ORGANIZATION IS LINE SEQUENTIAL.
    SELECT EMP-OUT ASSIGN TO 'PAYROLL.RPT'
        ORGANIZATION IS LINE SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
FD EMP-IN.
01 EMP-REC.
    05 EMP-ID        PIC 9(4).
    05 EMP-NAME      PIC X(20).
    05 GROSS-SALARY  PIC 9(6)V99.

FD EMP-OUT.
01 OUT-REC         PIC X(80).

WORKING-STORAGE SECTION.
01 WS-END-FILE       PIC X VALUE 'N'.
   88 END-OF-FILE   VALUE 'Y'.
   88 NOT-END-FILE  VALUE 'N'.
01 NET-SALARY        PIC 9(6)V99.
01 TAX-RATE          PIC 9V99 VALUE 0.20.
01 WS-TOTAL-GROSS    PIC 9(8)V99 VALUE ZERO.
01 WS-TOTAL-NET      PIC 9(8)V99 VALUE ZERO.
01 WS-COUNT          PIC 9(4) VALUE ZERO.
01 WS-DISPLAY-LINE   PIC X(80).

PROCEDURE DIVISION.
MAIN-PROCEDURE.
    OPEN INPUT EMP-IN
    OPEN OUTPUT EMP-OUT

    MOVE "         PAYROLL REPORT         " TO WS-DISPLAY-LINE
    WRITE OUT-REC FROM WS-DISPLAY-LINE
    MOVE "----------------------------------" TO WS-DISPLAY-LINE
    WRITE OUT-REC FROM WS-DISPLAY-LINE

    PERFORM UNTIL END-OF-FILE
        READ EMP-IN
            AT END MOVE 'Y' TO WS-END-FILE
        END-READ

        IF NOT-END-FILE
            ADD 1 TO WS-COUNT
            COMPUTE NET-SALARY = GROSS-SALARY - (GROSS-SALARY * TAX-RATE)
            ADD GROSS-SALARY TO WS-TOTAL-GROSS
            ADD NET-SALARY TO WS-TOTAL-NET

            STRING "ID: " DELIMITED BY SIZE
                   EMP-ID DELIMITED BY SPACE
                   "  Name: " DELIMITED BY SIZE
                   EMP-NAME DELIMITED BY SPACE
                   "  Gross: $" DELIMITED BY SIZE
                   GROSS-SALARY DELIMITED BY SPACE
                   "  Net: $" DELIMITED BY SIZE
                   NET-SALARY DELIMITED BY SPACE
                   INTO WS-DISPLAY-LINE
            WRITE OUT-REC FROM WS-DISPLAY-LINE
        END-IF
    END-PERFORM

    MOVE "----------------------------------" TO WS-DISPLAY-LINE
    WRITE OUT-REC FROM WS-DISPLAY-LINE
    STRING "Total Employees: " DELIMITED BY SIZE
           WS-COUNT DELIMITED BY SPACE
           "   Total Gross Salary: $" DELIMITED BY SIZE
           WS-TOTAL-GROSS DELIMITED BY SPACE
           "   Total Net Salary: $" DELIMITED BY SIZE
           WS-TOTAL-NET DELIMITED BY SIZE
           INTO WS-DISPLAY-LINE
    WRITE OUT-REC FROM WS-DISPLAY-LINE

    CLOSE EMP-IN
    CLOSE EMP-OUT
    STOP RUN.
          

DocuWriter.ai Output

Example COBOL Program Documentation (example-cobol.cob) 🏷️

Welcome to the Markdown Documentation of the file example-cobol.cob! In this document, we will explore:

  1. Introduction ✨
  2. Program Overview 🏗️
  3. Detailed Code Explanation 💡
  4. Flowchart Diagram (Conceptual) 🔀
  5. Key Variables and Purpose 📋
  6. File Input & Output Explanation 🔍
  7. Compilation & Execution Instructions ⚙️
  8. Conclusion 💬

Introduction ✨

This COBOL program, named PAYROLL, processes employee salary data from an input file and generates a payroll report. It demonstrates typical COBOL constructs such as:

  • DIVISIONS (IDENTIFICATION, ENVIRONMENT, DATA, and PROCEDURE).
  • FILE I/O (reading from an input file, writing to an output file).
  • STRING manipulation.
  • COMPUTE statements for tax calculation and net salary computations.
  • PERFORM UNTIL loops for file record processing.

Program Overview 🏗️

The example-cobol.cob file performs the following tasks:

  1. Open Input File (EMP-IN): Reads employee data which includes Employee ID, Name, and Gross Salary.
  2. Open Output File (EMP-OUT): Writes lines of text including a header, each employee’s payroll details, and totals at the end.
  3. Process Records and compute each employee’s Net Salary by applying a TAX-RATE (default 20%).
  4. Accumulate Totals of gross and net salaries for all processed employees.
  5. Write the summarizing totals to the output file and close all files.

Key Points in the Code

  • IDENTIFICATION DIVISION: Defines the program name (PAYROLL), author, and date.
  • ENVIRONMENT DIVISION: Specifies the files and how they are organized.
  • DATA DIVISION:
    • FILE SECTION: Layout of records for input and output files.
    • WORKING-STORAGE SECTION: Temporary variables, flags, accumulators (for totals).
  • PROCEDURE DIVISION: Main logic including opening files, processing records in a loop, formatting output, and closing files.

Flowchart Diagram (Conceptual) 🔀


 ┌─────────────────────────────┐
 │        Start Program        │
 └─────────────────────────────┘
               │
               ▼
 ┌─────────────────────────────┐
 │ Open EMP-IN & EMP-OUT Files │
 └─────────────────────────────┘
               │
               ▼
 ┌─────────────────────────────┐
 │   Write Report Header Line  │
 └─────────────────────────────┘
               │
               ▼
 ┌───────────────────────────────────┐
 │                 Read             │
 │            EMP-IN RECORD         │
 └───────────────────────────────────┘
               │
         ┌─────┴─────────────────┐
         │  End of EMP-IN? (Y/N) │
         └─────┬─────────────────┘
               ▼ (No)
 ┌─────────────────────────────┐
 │   Increment Employee Count  │
 └─────────────────────────────┘
               │
               ▼
 ┌─────────────────────────────┐
 │  Compute Net Salary =       │
 │ Gross - (Gross * TAX-RATE)  │
 └─────────────────────────────┘
               │
               ▼
 ┌─────────────────────────────┐
 │ Accumulate Gross & Net      │
 └─────────────────────────────┘
               │
               ▼
 ┌─────────────────────────────┐
 │  Format and Write Employee  │
 │       Detail to Output      │
 └─────────────────────────────┘
               │
               └───────── (Loop back to Read next record)
               │
               ▼ (Yes, End)
 ┌─────────────────────────────┐
 │ Write Totals to Output File │
 └─────────────────────────────┘
               │
               ▼
 ┌─────────────────────────────┐
 │   Close EMP-IN & EMP-OUT    │
 └─────────────────────────────┘
               │
               ▼
 ┌─────────────────────────────┐
 │          Stop Run           │
 └─────────────────────────────┘
          

Key Variables and Purpose 📋

VariablePIC / ValueDescription
EMP-ID9(4)Unique identifier for each employee.
EMP-NAMEX(20)Employee's name.
GROSS-SALARY9(6)V99Employee's gross salary (with decimals).
WS-END-FILEXFlag for end-of-file status.
NET-SALARY9(6)V99Calculated net salary after tax deduction.
TAX-RATE9V99 (0.20)Tax rate (default 20%).
WS-TOTAL-GROSS9(8)V99Accumulated total gross salary.
WS-TOTAL-NET9(8)V99Accumulated total net salary.
WS-COUNT9(4)Total number of employee records processed.

File Input & Output Explanation 🔍

  • EMP-IN:
    • File: EMPLOYEE.DAT
    • Contains employee records with Employee ID, Name, and Gross Salary.
  • EMP-OUT:
    • File: PAYROLL.RPT
    • Contains the formatted payroll report including details for each employee and summary totals.

Compilation & Execution Instructions ⚙️

  1. Compilation (using GnuCOBOL):
    
    cobc -x example-cobol.cob -o payroll
                  
  2. Execution:
    • Ensure EMPLOYEE.DAT is available.
    • Run the executable:
      
      ./payroll
                        
    • The report will be generated in PAYROLL.RPT.

Conclusion 💬

This documentation outlines the core functionality of the PAYROLL COBOL program. It demonstrates how employee data is read, processed, and summarized into a payroll report. Use this guide to better understand how legacy COBOL programs work and how you can extend or modernize them.

🏁 End of Documentation

Enjoy exploring COBOL and let DocuWriter.ai simplify your legacy projects!

Get started

Begin Understanding Your Legacy COBOL Projects Today