Menu

Parsing cobol file data values are coming as encrypted

Help
2019-01-11
2019-01-11
  • Mahendhar Reddy

    Mahendhar Reddy - 2019-01-11

    Hi bruce,
    i have copybook file and data file which is having binary data with .txt files. i am able to parse copybook(UTF-8) and data file(ANSI and tried with UTF-8 as well) values but the data file values are getting as encrypted. i tried with changing encoding value of file but the results are same. here i'm attaching my copybook and data file sample values(not full file but the format is same if needed i can share screenshot). please find the code snippet below

    CobolIoProvider ioprovider = CobolIoProvider.getInstance();
    FileInputStream copyStream = new FileInputStream (new File(filename));
    AbstractLineReader reader = ioprovider.newIOBuilder(copyStream, " test file copy book", ICopybookDialects.FMT_MAINFRAME)
    .setFont("CP037").setFileOrganization(Constants.IO_FIXED_LENGTH_RECORDS)
    .setSplitCopybook(CopybookLoader.SPLIT_NONE).newReader(datafilename);
    AbstractLine policy;
    Layout detail layout = reader.getLayout();
    details = layout.getFieldNameMap();
    StringBuffer stringwriter = new StringBuffer ();
    while ((policy=  reader.read())!=null){
    final AbstractLine policyF = policy;
    details.entrySet().stream().
    forEachOrdered (e->stringwriter.append(getCleanFeildValue(policyF, e)).append(",");
    stringwriter.append(System.lineSeparator());
    }
    
    private static String getCleanFeildValue(AbstractLine policyF, Entry<String, IFieldDetail> e){
    String value= policyF.getFieldValueIfExists(e.getKey()).asString();
    if( value.matches("[f]+")){
    Value = "";
    }
    return value;
    }
    
     
  • Mahendhar Reddy

    Mahendhar Reddy - 2019-01-11

    while reading i am also getting exception in getCleanFieldValue() method as
    net.sf.JRecord.Common.RecordException: DIS-TRR-SECONDS: Invalid Zoned Decimal: ???????

    i tried remove the exception occuring feilds in copy book and executed i'm getting exception for
    PIC S9(7)V99.
    PIC S999V COMP-3.
    PIC S9(07)V99 COMP-3.
    can you please help how to read these values and how to get string type values without encryption

     
  • Bruce Martin

    Bruce Martin - 2019-01-11

    I can not really tell anything from what you have provided I really need to see a data file & Copybook. I have tried to send you my direct e-mail

    Is this file from the mainframe ??? and have you transfered as EBCDIC (i.e. no translation of the file) also called a binary transfer.

    If you can look at the file in a normal text editor and can read it - you have a problem.

     

Log in to post a comment.

MongoDB Logo MongoDB