Parse COBOL Copybook-Style Fixed-Width Records
Convert fixed-width records defined by COBOL copybooks into CSV. Covers typical mainframe field layouts, PIC clauses, and data extraction.
Legacy Formats
Detailed Explanation
COBOL Copybook Records
COBOL copybooks define the structure of fixed-width records on mainframe systems. They specify field names, data types, and lengths using PIC (PICTURE) clauses. While this tool does not parse COBOL directly, you can translate copybook definitions into column definitions.
Translating PIC Clauses to Column Widths
| PIC Clause | Width | Description |
|---|---|---|
PIC X(10) |
10 | Alphanumeric, 10 characters |
PIC 9(5) |
5 | Numeric, 5 digits |
PIC 9(7)V99 |
9 | Numeric with implied decimal (7 integer + 2 decimal digits) |
PIC S9(5) |
5 | Signed numeric (sign may be in last byte) |
PIC X(3) |
3 | Alphanumeric, 3 characters |
Example Copybook
01 CUSTOMER-RECORD.
05 CUST-TYPE PIC XX.
05 CUST-ID PIC 9(8).
05 CUST-NAME PIC X(30).
05 CUST-BALANCE PIC 9(8)V99.
05 CUST-STATUS PIC X.
Corresponding Column Definitions
| Column | Width | Alignment | Trim |
|---|---|---|---|
| CUST-TYPE | 2 | Left | Yes |
| CUST-ID | 8 | Right | Yes |
| CUST-NAME | 30 | Left | Yes |
| CUST-BALANCE | 10 | Right | Yes |
| CUST-STATUS | 1 | Left | Yes |
Sample Data
01 12345678John Smith 000012345.67A
01 98765432Jane Doe 000098765.43A
02 11223344Bob Johnson 000000100.00I
Considerations
- The implied decimal in
PIC 9(8)V99means the value0000123456represents00001234.56. You may need post-processing to insert the decimal point - Signed numerics (
PIC S9(5)) may use an overpunch sign in the last byte, which requires special handling - EBCDIC-to-ASCII conversion must be done before this tool can process the data
Use Case
Migrating data from IBM mainframe COBOL applications to modern systems, converting batch file outputs for data warehousing, or extracting records from legacy VSAM or sequential files.