Not able to convert EBCDIC to ASCII

189 views
Skip to first unread message

Nitendra Dhaked

unread,
Sep 25, 2013, 3:39:46 AM9/25/13
to legsta...@googlegroups.com
Hi fady,

I am able to generate xsd schema from cobol copybook but when trying to convert ebcdic data to ascii data it throws error. 

com.legstar.coxb.transform.HostTransformException: ConversionException for element:NopostReason Cobol name:NOPOST-REASON Reason:Host data last byte is not a valid packed decimal byte. Host data at offset 2=0xd9e2
at com.legstar.coxb.transform.AbstractHostToJavaTransformer.transform(AbstractHostToJavaTransformer.java:273)
at com.legstar.coxb.transform.AbstractHostToJavaTransformer.transform(AbstractHostToJavaTransformer.java:212)
at com.legstar.test.coxb.mainframe.bind.ReportTapeNonmonChangesTransformers.toJava(ReportTapeNonmonChangesTransformers.java:76)
at EBCDICTOASCII.testReadFile(EBCDICTOASCII.java:66)
at Test.main(Test.java:9)


following are the code snippet 

                   ReportTapeNonmonChangesTransformers tf = new ReportTapeNonmonChangesTransformers();
                   File fi = new File("/home/cloudera/Desktop/BE000711.08232013.145747.TXT"); 
                   byte[] buffer = new byte[10750];
                   ZosVariableFileInputStream fis = new ZosVariableFileInputStream(fi);
                   int processed = 0;
  
                    HostTransformStatus status = new HostTransformStatus();
                    while ((fis.read(buffer, processed)) != -1)
                    {
                    ReportTapeNonmonChanges rtapechanges = tf.toJava(buffer, status);
                    processed = status.getHostBytesProcessed();
                   System.out.print(rtapechanges.getRecCodeBytes().getRecCodeKey());
                   }
             

this gives error on comp3 field.

Could you check what is the exact problem. 

PFA for cobol copybook EBCDIC binary file and xsd schema file.
mainframe.xsd
BE000711.08232013.145747.TXT
RPTSNOMN.cpy

Fady

unread,
Sep 25, 2013, 8:26:31 AM9/25/13
to legsta...@googlegroups.com
Your data does not match your copybook.

Looking into C:\Users\Fady\AppData\Local\Temp\BE000711.08232013.145747.TXT, the first bytes are:

 C8 C4 D9 E2 C3 E4 E2  

These are EBCDIC characters for  H  D  R  S  C  U  S 

You can check for yourself here: http://en.wikipedia.org/wiki/EBCDIC

Now, your copybook starts like this:

       01  REPORT-TAPE-NONMON-CHANGES.
           02  REC-CODE-BYTES.
               03  REC-CODE-KEY            PIC X.
               03  POST-NOPOST-KEY         PIC X.
               03  NOPOST-REASON VALUE +0  PIC S9(3)V    COMP-3.

This means that your data must contain something different from a character starting on the 3rd byte. But it contains character R then S and so forth. This is invalid for a COMP-3.

Hence the pretty explicit error message.






Nitendra Dhaked

unread,
Sep 27, 2013, 3:02:00 AM9/27/13
to legsta...@googlegroups.com
Hi fady,

could you check for this updated file, still i am getting same error.
BE000711.08232013.145747.TXT

Bonny Varghese

unread,
Jul 26, 2019, 10:38:21 AM7/26/19
to legstar-user
Hi,

Were you able to figure out the issue. 

Bonny
Reply all
Reply to author
Forward
0 new messages