NoSuchElementException when creating external record
Read Cobol data files in Java
Status: Beta
Brought to you by:
bruce_a_martin
Hello,
I use the below code for decoding an encrypted with COMP-3 file and I have an error at the line with final AbstractLineReader reader = ioBldr.newReader(dataFile);and when I debug, it reaches file CblIOBuilderMultiSchemaBase and at the lines: if (copybooks.size() == 1) { return copybooks.get(0).createExternalRecord();, the createExternalRecord method gets the exception.
I use 0.90 version for base jrecord and for cb2xml 1.0.
The code is below:
public static void parseEbcdicFile(final String copyBookFile, final String dataFile) throws IOException {
System.out.println("**************************************");
System.out.println("****** PARSING " + dataFile);
System.out.println("****** Copybook " + copyBookFile);
System.out.println("**************************************");
{
final ICobolIOBuilder ioBldr = JRecordInterface1.COBOL
.newIOBuilder(copyBookFile)
.setFont("cp273")
.setDialect(ICopybookDialects.FMT_MAINFRAME);
final AbstractLineReader reader = ioBldr.newReader(dataFile);
AbstractLine l;
while ((l = reader.read()) != null) {
System.out.println(">>>>>" + l.getFullLine());
System.out.print("<<<<<");
final FieldIterator iter = l.getFieldIterator(0);
while (iter.hasNext()) {
final AbstractFieldValue field = iter.next();
System.out.print("|" + field.getFieldDetail().getName() + "=" + field.asString());
}
System.out.println("");
}
reader.close();
}
}}
Anonymous
Whats the Cobol Copybook and what version of JRecord
I added both the copybook and the file that needs decryption and the version is 0.90
I added both the copybook and the file that needs to be decrypted and the version is 0.90
Correction Got this wrong - was looking at the wron File - I hve a number of user files
Do you have stack trace ???
I have not been able to replicate the problem. I wouyld guess there is a mismatch between JRecord Version and the cb2xml version
I will try build using Maven and see what I get.
Other issues:
Change the IoBuilder creation to
i.e. add in ** .setFileOrganization(Constants.IO_VB_DUMP)**
The Cobol copybook does not match the File (see the attached first record).
The first 2 bytes are text 11 (i.e. Pic 99), in the copybookits defined as s9(3) comp-3
Correction Got this wrong - was looking at the wron File - I hve a number of user files
Last edit: Bruce Martin 2019-06-29
this zip contains the pom files I have
thanks a lot for your help !!
and this is the stack trace
So I have cb2xml version 1.00 and jrecord-base version 0.90 and the other one, jrecord-common, version 0.90
The person who helped me the code has the following dependencies and said that this works:
But he does not use maven and I should use it....
Last edit: Dobre Mihaela 2019-06-28
Hi Bruce,
I am now using Jrecord version 0.81.3 along with cb2xml version 0.95.8 and I get the error The file "lexer.dat" is either missing or corrupted
Any thoughts on this?
I found an answer related to that, but according to it, my versions are okay
Don't know
I used an eclipse maven build of JRecord/cb2xml with and eclipse maven project using it - Seems to run Ok
Will attach
Hi Bruce,
thank you for your incredible support, in eclipse everything works !!
I have a final question for you. I replaced the input files and I get some errors saying "invalid packed decimal" or "invalid sign". Do you think this new file is not suitable for the font set, cp273?
it looks as terrible as the other one, having comp-3 values.
should I change anything in the code ?
The file AIDIS200_2019052818011625.txt is empty
Possible causes:
Low values/High values/spacesto indicate something (probably null)If you supply the file I will look at it.
the copybook is attached also
Hi Bruce,
I attach it again , hope it will work.Thanks a lot for your incredible help
That particular file is ascii - has it been through a EBCDIC --> ASCII transalation. This will screw up the file basically for comp-3 fields:
There iis a little on this in Question and Answer.
The RecordEditor can be useful for seeing what is going on See
Does not look really encouraging, I am not really sure what I could do.
Do you think that if the file would be converted from ASCII to EBCDIC, it would work ?
I had a second look - it has been converted to UTF-8 (rather than ascii, not a huge difference). The result is much the same.
Do you think that if the file would be converted from ASCII to EBCDIC - No definitely not
The only sure way is to retransmit the file from the mainframe as an EBCDIC file.