I am currently facing a weird issue.
I have a working program which uses Jrecord to read an ebcdic file and displays the contents in ascii.
This is working correctly as expected in Eclipse.
But when the program is packaged as a Runnable jar and executed on Linux server. the output is having special chars, and comp-3 fields are not correctly converted.
But the same jar when run in windows command prompt will produce proper output.
Has anyone faced this issue earlier?
Appreciate your guidance.
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
output is having special chars, and comp-3 fields are not correctly converted - this suggest to me there is some sort of conversion occuring on the file. Either a Ebcdic-Unicode or ebcdic to ascii.
I really need to see the code (and probably a data file) to understand what is going on. I will try and send you my direct e-mail address incase you do not want to put the program up on the web-site
One possible cause is on Windows the default encoding is ascii while most linux's it is utf-8.
Two things I would suggest (if you have not done so):
Make sure you use the same file on linux and windows
Check for .setFont("") this will perform differetly on linux as apossed windows i.e
ioBuilder.setFont("")
Last edit: Bruce Martin 2018-09-27
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This code should work the same on linux as on Windows. Its clutching at straws time.
I think it is time to investigate java: which version of java is running on linux The encodings CP037 / IBM037 are in an Optional jar. If this is jar is missing / corrupted, java will still work (provided you dot use thing like cp037). Please run the following code on the linux system (it will thow an exception if cp037 is missing):
Thanks for the inputs.
I have tried out the mentioned code above and it runs fine without throwing any errors oon linux box.
However, when I was looking at the data, i could see that the first line is converted perfectly, but few fields from the 2nd line are being concated at the end of 1st line and the fields starting from 2nd line are not correctly extracted.
As I cant give the actual data, PFB an example of how the data appears in Linux output.
Eg:
row1: line1field1 |line1field2 |line1field3 |line1field4 |line1field5 |line1field6 |line2field1 |line2field2_split1|line2field2_split2
row2: |line2field3_split1|line2field3_split2|line2field4_split1|line2field4_split2 etc....
This is only happening on Linux, but windows cmd and eclipse output are perfect.
Hope to resolve this soon!
Thanks in advance for the help!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Bruce An update on the issue.
We moved the .java file to linux and compiled it on the server and ran the class files. it runs without any issue :)
But if we package the jar in eclipse and use it on Linux the issue turns up.
Looks like we'll have to proceed with the .class files we have generated, instead of using the jar.
Thanks for all your support!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Bruce,
We went throu the code and the copybook files again, and you were right in pointing out that this issue might be due to mismatch between data fie and copybook.
It turns out there are a few fields added to the file by upstream teams, but they failed to update the changes in copybook.
After the updation we were able to read the files correctly.
One more thing we are considering is reading the EBCDIC files that are present on HDFS.
Our use case would be to Read EBCDIC file present on HDFS and print out converted ascii data.
Are there any other libraries tat needs to be used for this use case?
Any sample code available would be helpful as well!
Request you to point me in right direction.
Thanks for all the help!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Bruce so much. I was using older version of Java. I have one query.
I'm able to convert EBCDIC data using copybook (.cbl format)
Now, If we use .cbl format ,then we have to manuall enter the field names in our code to get data.
I was thinking, whether you have any utility which take copybook data in XML format and EBCDIC data and automatically extract the field name and process the data.
I have tried cbl2xml and it works well, I'm able to get Copybook data in XML format. But when i try to parse this XML file. It shows error.
Which-ever way you run CodeGen, there are three basic Templates:
standard This template generates
a Cobol Field Nameclass
sample read / write programs. These are not intended to be fully working programs but sample programs to get you started
lineWrapper this template generates
a Cobol Field Name class
a Wrapper class (for JRecord lines) where access the fields by java getter/setter's for each field.
Sample read / write programs
pojo - This template generates a pojo class, cobol to java-pojo class, IO Builder for the pojo and pojo readers/writers. It works well for simple Cobol files, for
more complicated files (e.g. with complicated redefines) you are probably better using one of the above
The standard template is probably what you are currently reting to achieve. Although the other templates ma be useful.
The Code for CodeGen is in Source/Other_Source/JRecord_CodeGen directory of the JRecord zip files. It uses Velocity 1.7 templates to generate the Code.
If you want to write generic programs I can tell you how to get at the schema information.
Last edit: Bruce Martin 2018-10-30
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I am currently facing a weird issue.
I have a working program which uses Jrecord to read an ebcdic file and displays the contents in ascii.
This is working correctly as expected in Eclipse.
But when the program is packaged as a Runnable jar and executed on Linux server. the output is having special chars, and comp-3 fields are not correctly converted.
But the same jar when run in windows command prompt will produce proper output.
Has anyone faced this issue earlier?
Appreciate your guidance.
Thanks
output is having special chars, and comp-3 fields are not correctly converted
- this suggest to me there is some sort of conversion occuring on the file. Either a Ebcdic-Unicode or ebcdic to ascii.I really need to see the code (and probably a data file) to understand what is going on. I will try and send you my direct e-mail address incase you do not want to put the program up on the web-site
One possible cause is on Windows the default encoding is ascii while most linux's it is utf-8.
Two things I would suggest (if you have not done so):
.setFont("")
this will perform differetly on linux as apossed windows i.eLast edit: Bruce Martin 2018-09-27
Hi Bruce,
Can you provide the code link which is used for converting ebcdic to ascii using java.
For JRecord use the setFont option, for US EBCDIC (cp037 or IBM037)
There are lot of ebcdic's though. German EBCDIC is cp273/IBM273
I java in general you can do
Generate JRecord code
If you use the code-generator in the recordeditor you can specify a
It should work out you have an ebcdic file and generate the appropriate code
see StackOverflow answer
Hi bruce
Thanks for your input!
Below is the partial code we are using, to create a IOBuilder and reader :
I have tried the .setFont option with both cp037 and IBM037 values, but the same behaviour is observed.
I will not be able to share the actual data as it is not permitted.
Appreciate your guidance.
Thank you!!
Last edit: Bruce Martin 2018-09-28
This code should work the same on linux as on Windows. Its clutching at straws time.
I think it is time to investigate java:
which version of java is running on linux
The encodings CP037 / IBM037 are in an
Optional
jar. If this is jar is missing / corrupted, java will still work (provided you dot use thing likecp037
). Please run the following code on the linux system (it will thow an exception if cp037 is missing):It may be worth trying on a different Linux instalation -
You could install Virtualbox and install a recent Linux distribution (I would suggest a light weight version e.g. LUBUNTU)
Last edit: Bruce Martin 2018-09-28
Hi Bruce
Thanks for the inputs.
I have tried out the mentioned code above and it runs fine without throwing any errors oon linux box.
However, when I was looking at the data, i could see that the first line is converted perfectly, but few fields from the 2nd line are being concated at the end of 1st line and the fields starting from 2nd line are not correctly extracted.
As I cant give the actual data, PFB an example of how the data appears in Linux output.
Eg:
row1: line1field1 |line1field2 |line1field3 |line1field4 |line1field5 |line1field6 |line2field1 |line2field2_split1|line2field2_split2
row2: |line2field3_split1|line2field3_split2|line2field4_split1|line2field4_split2 etc....
This is only happening on Linux, but windows cmd and eclipse output are perfect.
Hope to resolve this soon!
Thanks in advance for the help!
That looks like a mismatch between the copybook and the Data. I would be checking the file and copybook are the same in Windows & linux.
I suggest Stting up a directory containing:
All jars
The Cobol Copybook
* File being read.
Run the program on Wandows then move directory to linux and run it again (or vice versa).
It is probably be a small difference between the way things are setup in windows and linux
Hi Bruce An update on the issue.
We moved the .java file to linux and compiled it on the server and ran the class files. it runs without any issue :)
But if we package the jar in eclipse and use it on Linux the issue turns up.
Looks like we'll have to proceed with the .class files we have generated, instead of using the jar.
Thanks for all your support!
At least you got it working. I presume there is an issue with your eclipse setup / build job
Hi Bruce,
We went throu the code and the copybook files again, and you were right in pointing out that this issue might be due to mismatch between data fie and copybook.
It turns out there are a few fields added to the file by upstream teams, but they failed to update the changes in copybook.
After the updation we were able to read the files correctly.
One more thing we are considering is reading the EBCDIC files that are present on HDFS.
Our use case would be to Read EBCDIC file present on HDFS and print out converted ascii data.
Are there any other libraries tat needs to be used for this use case?
Any sample code available would be helpful as well!
Request you to point me in right direction.
Thanks for all the help!
Have a look at this discaussion:
it lists several packages that use JRecord with HADOOP, not sure how relavent they are. Packages include:
I you can gett record as an array of byes, another option could be to use a IByteRecordReader . See:
Finally creating a CodeGen Template for Hadoop might be possible
Hello Bruce, I;m getting the flollowing error
My code is below::
Please help!! i'm using latest JRecorder version to convert EPCDIC data.
Last edit: Jasminder pal s sehgal 2018-10-19
Which version of Java ???
Also I will attach cb2xml.jar just in case your jar has been corrupted
Last edit: Bruce Martin 2018-10-19
Thanks Bruce so much. I was using older version of Java. I have one query.
I'm able to convert EBCDIC data using copybook (.cbl format)
Now, If we use .cbl format ,then we have to manuall enter the field names in our code to get data.
I was thinking, whether you have any utility which take copybook data in XML format and EBCDIC data and automatically extract the field name and process the data.
I have tried cbl2xml and it works well, I'm able to get Copybook data in XML format. But when i try to parse this XML file. It shows error.
I'm getting following error
Thanks alot, You are god of COBOL :))
Last edit: Jasminder pal s sehgal 2018-10-29
Ok Bruce, I got the error. Cb2XMl generates XML with follwing header
But, Your code wants to parse XML in following format :
So, what should i do now?
To process cb2xml xml files:
but there is a much better option - CodeGen utility, this can be run from
Have a look at Generating Java JRecord Code from a Cobol Copybook
Which-ever way you run CodeGen, there are three basic Templates:
standard This template generates
lineWrapper this template generates
pojo - This template generates a pojo class, cobol to java-pojo class, IO Builder for the pojo and pojo readers/writers. It works well for simple Cobol files, for
more complicated files (e.g. with complicated redefines) you are probably better using one of the above
The standard template is probably what you are currently reting to achieve. Although the other templates ma be useful.
The Code for CodeGen is in Source/Other_Source/JRecord_CodeGen directory of the JRecord zip files. It uses Velocity 1.7 templates to generate the Code.
If you want to write generic programs I can tell you how to get at the schema information.
Last edit: Bruce Martin 2018-10-30
On a side note RecordEditor and ReCsvEditor can generate Java~JRecord code to read/write the CSV for you.
Thanks, It helped.
May the force be with you :))