Convert VB EBCDIC file to ASCII, where copybook records are 01 separated

495 Views Asked by At

We have an EBCDIC file that is of VB(variable length) records. Correspond to this EBCDIC we have copybook in which records are separated with 01 type & individual record also contains packed decimal fields. Kindly suggest how we can convert this kind of EBCDIC file to ASCII.

RecordEditor we cannot install due to company security policy. we are using JRecord Library and we are creating object like:

ICobolIOBuilder iob = CobolIoProvider.getInstance() 
    .newIOBuilder(copybookName) 
    .setCopybookFileFormat(Convert.FMT_MAINFRAME) 
    .setFileOrganisation(Constant.IO_VB) 
    .setSplitCopybook(CopybookLoader.SPLIT_01_LEVEL) .setFont("cp037");

After that when we read the file line by line using AbstarctLineReader it is coming with lots of special characters. Kindly suggest on this.

3

There are 3 best solutions below

2
On

Basics

Before you do anything else, you need to:

  • work how differentiate the record various record types. It could be a field at the start of the record (may have record-type in the name).
  • If you are transferring a file from say a mainframe you need to be careful

Conversion

Package that may be useful

  • The RecordEditor should be able to edit the file using the Cobol Copybook (you need to import the Copybook). The RecordEditor can also write the file as Xml.

  • The java projects JRecord and its sub projects like CobolToXml can do the conversion. The RecordEditor has some Code Generation options for JRecord

Finally have a look at how to generate Java~JRecord code

2
On

Packed decimal, in EBCDIC, looks like this:

005F  005C  005D

The first value, 005F, is a PIC 999 COMP-3 unsigned value of 5. Each digit is represented by a byte, and the last byte is the sign byte. Each byte holds two decimal digits, except for the rightmost byte. The rightmost byte holds the rightmost digit in the left half-byte and the sign in the right half-byte.

The second value, 005C, is a PIC S999 COMP-3 positive value of 5.

The third value, 005D, is a PIC S999 COMP-3 negative value of -5.

Now, how packed decimal looks after you've converted it to ASCII, I have no idea. You'll have to add some lines of your ASCII file to the question, in hexadecimal, so we can see what the converter did.

0
On

Packed decimal is not "in EBCDIC", nor in any other code page. Packed decimal is a binary number format that the IBM mainframe (and other) processors support with a set of native machine instructions. It is an implementation of the BCD (binary coded decimal) format. See Binary coded decimal on Wikipedia.