I am trying to read a EBCDIC file and convert it to ASCII format in Java, with a help of copybook. I am using JRecord to read the copybook. So now, how do I get the field level from the copybook using JRecord?
Edit 1:
Kindly excuse me for a vague question. I have no experience in mainframe or cobol. I am adding few more details if it could help.
My source file contains multiple transaction details. The copybook contains the information on the transaction and the fields relating to that particular transaction.
I have to split the each transaction and its fields to a separate file(containing one transaction and respective fields).
In attached copybook, the field in line 1 can have values from line 2 to line 4. If the EXTRA-TYPE is 01, then I have to read fields in line 6 to line 11. Similarly, if the EXTRA-TYPE is 02, then I have to read fields in line 12 to line 16. I am trying to split the Transaction type and its respective fields dynamically. (I need to get the start and end position of the fields with respect to the transaction type in line 1)How do I achieve this in Java?
I appreciate your help.
Have a read of http://www.catb.org/~esr/faqs/smart-questions.html or https://www.mikeash.com/getting_answers.html about asking questions
But any way:
Using the Code Generation
Download the Recordeditor from https://sourceforge.net/projects/record-editor/files/Test/Version_0.98.3/ the USB version does not need to be installed - just unzip it
Start the RecordEditor and select the generate option
Press the Generate code button, The program should generate some sample code like:
Why do you need to get the Field Level ???. To convert a file to ascii you do not need the Field Level.
Utility Conversion Program
To Convert a Cobol File to ascii you can use one of the utility programs:
Java processing of a Cobol file
If you want to do some processing on the File, you can use the Generate function of the RecordEditor to generate sample JRecord code from the Cobol copybook.
Code generated with standard template
If you use the standard template, the RecordEditor will generate code like:
Code generated with lineWrapper template
Generic Cobol processing
If you want to do more generic processing you can use a fieldIterator:
JRecord Examples
In the latest release of JRecord 0.81.4 there are examples in the Source/JRecord_IO_Builder_Examples/src directory
Tree processing
If you need to access level numbers with JRecord, use CobolSchemaReader.newCobolSchemaReader(...) interface.
Also you could look at the code for Cobol2Xml sub-project. It does
tree
processing by extending CobolSchemaReader