Preparing mainframe EBCDIC files for SSIS
SQL Server Integration Services reads flat files well, provided they are in ASCII or Unicode and each column has a clear delimiter or width. Files that come from an IBM mainframe are different. They use the EBCDIC character set, they are described by a COBOL copybook rather than a header row, and numeric fields are often stored as packed decimal (COMP-3), which no standard flat file source can interpret. Teams usually find this out after the first import produces unreadable columns.
TextPipe converts the file before SSIS sees it. You supply the copybook, TextPipe works out the record layout, translates the text fields to ASCII, unpacks the numeric fields and writes either delimited or fixed-width output. SSIS then treats the result as an ordinary flat file.
Sample input and output
Consider this fragment of a copybook:
01 CUST-REC.
05 CUST-ID PIC 9(6).
05 CUST-NAME PIC X(20).
05 BALANCE PIC S9(7)V99 COMP-3.
Each record in the data file is 31 bytes long. Opened in a text editor the name looks like garbage and the balance is a handful of unprintable bytes. After conversion the same record reads:
000123,JOHN SMITH,1234.56
The balance has been unpacked from five bytes of COMP-3 into a readable decimal value with the decimal point in the right place, and the sign is preserved for negative amounts.
Typical settings
- Copybook import: load the copybook and select the record layout that matches the file.
- Code page: choose the EBCDIC variant used by the source system, for example US EBCDIC 037.
- Output format: delimited with a header row for easy column mapping in SSIS, or fixed width for a fixed-width source.
- Record handling: support for REDEFINES and OCCURS clauses, and for files with no line breaks between records.
Practical applications
Data warehouse teams use the conversion as the first step of a nightly package: TextPipe runs from the command line, writes the converted file to a landing folder, and SSIS picks it up. It also suits one-off migrations, where a bank or insurer moves historical mainframe data into SQL Server for reporting.
Common pitfalls
- If the file was transferred in text mode, bytes may already have been altered. Transfer mainframe data in binary mode.
- A copybook that does not match the file produces shifted columns. Check the first few records against known values.
- Variable-length records need the record descriptor words to be handled before conversion.
Related pages
Read the EBCDIC to ASCII converter and the COMP-3 packed decimal guide for field-level detail, and the SQL Server bulk insert guide for loading the output. The banking and finance case study describes a COBOL conversion project, and the data conversion solutions page lists related tasks.