There are 5 main types of Mainframe EBCDIC copybook that TextPipe will help you with:
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.
![]() |
In our sample copybook below, each record starts with a 3 byte field (T-TRAA-LEN), followed by a 5 letter record type id, T-REC_ID, which has values of #REC#, #TRAA, #TRAD etc. There are other fields beyond this that are unique to this 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'.
...
With TextPipe 11+ (download), the steps to convert a multi-segment cobol file are:
Here is how it looks in TextPipe:
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.
![]() |
With TextPipe (download), the steps are
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.
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'.
...
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
When something matches this pattern, it must be a record of type #TRTS, and it gets passed unchanged to the subfilter:
Pro Tip: We can easily copy this structure by selecting the top filter, and choosing the [x2] button in the footer.
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.
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) ]
Then you're ready to drag and drop your mainframe file into TextPipe and click [Go] or press [F9]!
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!
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.
Please drop us an email with your copybook support2@datamystic.com
|