EBCDIC to ASCII, and ASCII to EBCDIC converter tool

TextPipe Pro is a robust EBCDIC to ASCII conversion utility. Once your files are decoded from EBCDIC into an ASCII text file in CSV, Tab, XML, JSON or other delimited format, you can load them into a database, or extract the information for other uses. TextPipe translates the widest set of mainframe data, which can vary due to code pages, Cobol compiler dialect and mainframe host machine byte-ordering.

You can also use TextPipe to convert ASCII files to EBCDIC format.


Free 10 Day Trial - No Credit Card Required

Once you drag and drop your mainframe files into TextPipe, you choose which filters will be used to convert the file:

Sometimes TextPipe won't be able to parse your copybook - due to PIC clauses missing trailing periods, comments in the wrong spot, bizarre line breaks or field names etc. Please just send us the copybook or filter and we'll be happy to help.

When a Mainframe EBCDIC copybook consists of multiple records, you need to separate them out into a general structure, with each record type going to a new file for clarity and ease of loading/processing. TextPipe 11 makes this easy.

Sample Multi-Segment Mainframe EBCDIC Copybook

In our sample copybook below, the second field of every segment contains a 5 character record type id, T-REC_ID, which has values of #REC#, #TRAA, #TRAD etc. Fields beyond this are unique to each segment. Note: Often, the record type field's VALUES are not included in the copybook, but has to be read from the comments or documentation. In these cases the record type field usually has a constant name like REC-ID.

05 T-REC.
10 T-REC-LEN PIC S9(4) COMP VALUE 68.
10 T-REC-ID PIC X(5) VALUE '#REC#'.
10 T-REC-STAT PIC X VALUE 'N'.
...

05 T-TRAA.
10 T-TRAA-LEN PIC S9(4) COMP VALUE 69.
10 T-REC-ID PIC X(5) VALUE '#TRAA'.
10 T-TRAA-STAT PIC X VALUE 'N'.
...

05 T-TRAC.
10 T-TRAC-LEN PIC S9(4) COMP VALUE 68.
10 T-REC-ID PIC X(5) VALUE '#TRAC'.
10 T-TRAC-STAT PIC X VALUE 'N'.
...

05 T-TRAD.
10 T-TRAD-LEN PIC S9(4) COMP VALUE 199.
10 T-REC-ID PIC X(5) VALUE '#TRAD'.
10 T-TRAD-STAT PIC X VALUE 'N'.
...

Multi-segment COBOL copybook conversion

With TextPipe 11+ (download), the steps to convert a multi-segment cobol file are:

  1. Open TextPipe, and drag and drop your binary file that you want to convert (this file is in EBCDIC, not ASCII)
  2. From the Filters to Apply tab, Add a Filter Library\Mainframe\Mainframe copybook master record, and set the general options such as the output format (CSV, Tab, Pipe, XML, ;-delimited, JSON, SQL Insert script)
  3. Set the name of the field that contains the Record Type e.g. T-REC-ID, RECORD-TYPE. This field in each segment tells TextPipe which segment type is being processed
  4. Set the base output filename - this is the base folder and file that will be used for each segment. The name of the file will be base output filename plus the Segment Type
  5. Add one or more Filter Library\Mainframe\Mainframe copybook child record as subfilters (ie inside) the Mainframe copybook master record. You can drag child filters inside the master filter. These child filters inherit settings from their parent.
  6. In each child record), set the child record type (e.g. #REC#, #TRAA, #TRAD, A, B, C, 01, 02, 03) and paste in the associated copybook. If TextPipe complains about the format of your copybook, please contact support.

When a Mainframe EBCDIC copybook consists of multiple records, you need to separate them out into a general structure, with each record type going to a new file for clarity and ease of loading/processing. TextPipe makes this easy.

Here is how it looks:

   

This results in the followings files being output

  1. User's Desktop\#REC#.csv - #REC# segments
  2. User's Desktop\#TRAA.csv - #TRAA segments
  3. User's Desktop\#TRAB.csv - #TRAB segments
  4. User's Desktop\#TRAC.csv - #TRAC segments
  5. User's Desktop\#TRAD.csv - #TRAD segments


Free 10 Day Trial - No Credit Card Required

Mainframe EBCDIC copybook filter design pattern

Sometimes the segment types can be a range of values, like 00-30, which could require a huge number of child records to be added. An alternative approach is available which allows you to use a pattern match to match the record type. With TextPipe (download), the steps are

  1. Use an EasyPattern match to identify each record type we have in the file – using the record header
  2. Pass this record header with its associated data to a subfilter
  3. The subfilter handles just that record type, and puts each record type in a new file.

In our sample file, each record starts with a 3 byte field which we will ignore, followed by a 5 letter record type id, #REC#, #TRAA, #TRAD etc. There is also a field following this record id, but we don't need it, and the value might not always be 'N'. Note: Often, the record type field's VALUES are not included in the copybook, but has to be read from the comments or documentation. In these cases the record type field usually has a constant name like REC-ID.

Sample Mainframe Copybook

05 T-REC.
10 T-REC-LEN PIC S9(4) COMP VALUE 68.
10 T-REC-ID PIC X(5) VALUE '#REC#'.
10 T-REC-STAT PIC X VALUE 'N'.
...

05 T-TRAA.
10 T-TRAA-LEN PIC S9(4) COMP VALUE 69.
10 T-TRAA-ID PIC X(5) VALUE '#TRAA'.
10 T-TRAA-STAT PIC X VALUE 'N'.
...

05 T-TRAC.
10 T-TRAC-LEN PIC S9(4) COMP VALUE 68.
10 T-TRAC-ID PIC X(5) VALUE '#TRAC'.
10 T-TRAC-STAT PIC X VALUE 'N'.
...

05 T-TRAD.
10 T-TRAD-LEN PIC S9(4) COMP VALUE 199.
10 T-TRAD-ID PIC X(5) VALUE '#TRAD'.
10 T-TRAD-STAT PIC X VALUE 'N'.
...

Records

The general TextPipe pattern for each record type within the file looks like this:

   

Let's dig into this.

The first step is an EasyPattern (a user-friendly type of pattern match). It looks for

  1. The start of the text, followed by
  2. Any 3 characters (the PIC S9(4) COMP field we are ignoring), followed by
  3. the EBCDIC characters #TRTS. (Remembering that PC's use ASCII, we need to specify the literal is EBCDIC), followed by
  4. 65 other characters – the rest of the record

When something matches this pattern, it must be a record of type #TRTS, and it gets passed unchanged to the subfilter:

  1. The Mainframe Copybook filter applies just the copybook segment that relates to the #TRTS record
  2. The result goes to the file TRTS-records.txt on your desktop
  3. The text is then prevented from continuing in the filter – it stops dead here.

Pro Tip: We can easily copy this structure by selecting the top filter, and choosing the [x2] button in the footer.

Working out the copybook size

When we paste each copybook fragment into a mainframe copybook filter, we can click the [Show Parse Tree] button to find out the record length. e.g.

	

-01 COPYBOOK 1-73 Length:73
05 T-TRAA 1-73 Length:73
10 T-TRAA-LEN S9(4) COMP-3. 1-3 Length:3
10 T-TRAA-ID X(5). 4-8 Length:5
10 T-TRAA-STAT X(1). 9 Length:1
10 T-TRAA-COMPL X(1). 10 Length:1
10 T-TRAA-COM S9(4) COMP-3. 11-13 Length:3
10 T-TRAA-DATA 14-73 Length:60

Once we know the length is 73, we just subtract 8 from it, (the first 3 characters followed by the 5 character record type = 8) to find out the remaining characters we need, in this case, 65:

	[ TextStart, 3 chars, EBCDIC('#TRAA'),
	65 chars ]

We also have to grab the record type TRAA from the copybook and put it into the pattern match, and also into the output filename.

	%USERPROFILE%\Desktop\TRAA-Records.txt

Then we move onto the next record type.

Master record match

Once we have setup all the record types, we need to gather ALL the record patterns into one MASTER pattern match at the top of the list.

   

The master copybook pattern match looks like this:

[
	TextStart,
3 chars,
EBCDIC('#'),
(EBCDIC('TRTS'), 65 chars)
or
(EBCDIC('TRAA'), 65 chars)
or

..one line for each record type..

(EBCDIC('TRTS'), 29 chars) ]

Ready to Rock 'n' Roll!

Then you're ready to drag and drop your mainframe file into TextPipe and click [Go] or press [F9]!

Errors?

If the error log reports that there were extra bytes in the file that could not be matched, this indicates that

May the force be with you!

Automation

Once tested, the TextPipe filter can be run automatically or on a schedule from the command line. It can also be controlled by other software using COM.

Need Help With Your Copybook?

Please drop us an email with your copybook support2@datamystic.com

 
Convert mainframe files today

copybook, cobol copybook, what is a copybook, copybook in mainframe, copy book cobol, copybooks mainframe, cobol copy book, copybook mainframe, what is cobol copybook, mainframe copybook, copybook definition, ebcdic to ascii converter,ebcdic to ascii file converter,convert ebcdic to ascii,how to convert ebcdic to ascii,ebcdic to ascii conversion tool,mainframe ebcdic to ascii conversion,Monarch Data Pump,Data Junction