Menu

#27 NoSuchElementException when creating external record

v1.0_(example)
open
None
1
2019-07-03
2019-06-27
No

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();
}

}}

Discussion

  • Bruce Martin

    Bruce Martin - 2019-06-27

    Whats the Cobol Copybook and what version of JRecord

     
  • Anonymous

    Anonymous - 2019-06-27

    I added both the copybook and the file that needs decryption and the version is 0.90

     
  • Dobre Mihaela

    Dobre Mihaela - 2019-06-27

    I added both the copybook and the file that needs to be decrypted and the version is 0.90

     
  • Bruce Martin

    Bruce Martin - 2019-06-28

    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

        final ICobolIOBuilder ioBldr = JRecordInterface1.COBOL
                .newIOBuilder(copyBookFile)
                .setFont("cp273")
                .setFileOrganization(Constants.IO_VB_DUMP)
                .setDialect(ICopybookDialects.FMT_MAINFRAME);
    

    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
  • Dobre Mihaela

    Dobre Mihaela - 2019-06-28

    this zip contains the pom files I have
    thanks a lot for your help !!

     
  • Dobre Mihaela

    Dobre Mihaela - 2019-06-28

    and this is the stack trace

     
  • Dobre Mihaela

    Dobre Mihaela - 2019-06-28

    So I have cb2xml version 1.00 and jrecord-base version 0.90 and the other one, jrecord-common, version 0.90

     
  • Dobre Mihaela

    Dobre Mihaela - 2019-06-28

    The person who helped me the code has the following dependencies and said that this works:

    <dependency org="net.sf" name="cb2xml" rev="0.81.3" conf="*->default" transitive="false"/>
    <dependency org="net.sf.jrecord" name="cobol2cobol" rev="0.81.3" conf="*->default" transitive="false"/>
    <dependency org="net.sf.jrecord" name="cbl2xml" rev="0.81.3" conf="*->default" transitive="false"/>
    <dependency org="net.sf.jrecord" name="jrecord" rev="0.81.3" conf="*->default" transitive="false"/>
    <dependency org="net.sf.jrecord" name="jrecord-test" rev="0.81.3" conf="*->default" transitive="false"/>
    <dependency org="net.sf.jrecord" name="cbl2xml-xml2cbl" rev="0.81.3" conf="*->default" transitive="false"/>
    

    But he does not use maven and I should use it....

     

    Last edit: Dobre Mihaela 2019-06-28
  • Dobre Mihaela

    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

     
    • Bruce Martin

      Bruce Martin - 2019-06-29

      Don't know

       
  • Bruce Martin

    Bruce Martin - 2019-06-29

    I used an eclipse maven build of JRecord/cb2xml with and eclipse maven project using it - Seems to run Ok

    Will attach

     
  • Dobre Mihaela

    Dobre Mihaela - 2019-07-01

    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 ?

     
    • Bruce Martin

      Bruce Martin - 2019-07-02

      The file AIDIS200_2019052818011625.txt is empty

      Possible causes:

      • Looking at the wrong record type.
      • Field is uninitialised/not relavent in some cases
      • The move Low values/High values/spaces to indicate something (probably null)

      If you supply the file I will look at it.

       
  • Dobre Mihaela

    Dobre Mihaela - 2019-07-01

    the copybook is attached also

     
  • Dobre Mihaela

    Dobre Mihaela - 2019-07-02

    Hi Bruce,

    I attach it again , hope it will work.Thanks a lot for your incredible help

     
    • Bruce Martin

      Bruce Martin - 2019-07-02

      That particular file is ascii - has it been through a EBCDIC --> ASCII transalation. This will screw up the file basically for comp-3 fields:

      • most will be unchanged
      • Some will be valid but have the wrong value (e.g. x'40' --> x'20')
      • Some will be invalid

      There iis a little on this in Question and Answer.

      The RecordEditor can be useful for seeing what is going on See

       
  • Dobre Mihaela

    Dobre Mihaela - 2019-07-02

    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 ?

     
  • Bruce Martin

    Bruce Martin - 2019-07-03

    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

    • Take the space char x'20', most likely it started as x'40' but it might of started as x'20'
    • in some case 2 ebcdic (mainly special chars) could be translated to a single asci/utf-8 character

    The only sure way is to retransmit the file from the mainframe as an EBCDIC file.

     

Anonymous
Anonymous

Add attachments
Cancel