Menu

Data type

2007-12-07
2013-05-13
  • Nobody/Anonymous

    I just download and give cobol2j a try.  For the first run, I got the data file converted to XML file successfully.  This is great.  But for the second run, I got a NumberFormatException.  It seems to me that cobol2j does not handle comp-3 data type.  Is this correct?

     
    • Paweł Mączka

      Paweł Mączka - 2007-12-07

      cobol2j DOES SUPPORT COMP-3. If you have NumberFormatException then please double check data definition. Please ensure if you have comp-3 data or maybe comp only. The first case requires that field definition attribute "packed" set to "true". In the second case you should use packed "false" or binary type "B" in the field definition. See type table on: http://cobol2j.sourceforge.net/manual.html
      Here is similar problem:
      https://sourceforge.net/tracker/index.php?func=detail&aid=1532075&group_id=156330&atid=799351

      I am ready to help you also with some probe data you converting and definition you try to use.
      How did you created data definition ? With Cobol copybook or from scratch ? There is upload facility in "Support request" tracker.
      Alternative you can paste full log/error message with the field data in hex format here as response.

      hope this helps
      Paweł Mączka

       
    • Nobody/Anonymous

      Paweł Mączka,

      Thank you for the quick response. 

      Actually, I was wrong.  My comp-3 field came after comp-1 and comp-2 fields.  After removing the comp-1 and comp-2 fields, cobol2j reads comp-3 field fine. 

      So, my new question is: Can cobol2j handle comp-1 and comp-2?  Thanks.

       
    • Paweł Mączka

      Paweł Mączka - 2007-12-12

      cobol2j DOES SUPPORT :
          * Binary            define in xc2j with Type=B and Packed=false
          * Computational (comp)    define in xc2j with Type=9 and Packed=false
          * Comp-1            define in xc2j with Type=9 and Packed=false
          * Comp-2            define in xc2j with Type=9 and Packed=false
          * Comp-3            define in xc2j with Type=9 and Packed=true
          * Packed Decimal        define in xc2j with Type=9 and Packed=true

      regards
      Paweł

       
    • Nobody/Anonymous

      Hi Paweł,

      I am not sure why but when I have comp-1 and comp-2 defined in the copybook, the xc2j lists    them as FieldsGroup but I am expecting FieldFormat.  This is the reason comp-1 and comp-2 does not work.  Please see f-comp-1-item and f-comp-2-item below.

      Inside copybook:

             01  out-rec.
                 05  f-tables occurs 2 times.
                     10 f-comp-1-item                comp-1.
                     10 f-comp-2-item                comp-2.
                     10 f-comp-3-item   pic s9(9)V99 comp-3.

      Inside xc2j:

      <FileFormat
        ConversionTBL="net.sf.cobol2j.tables.EBCDIC_037_TO_ISO_8859_1"
        distinguishFieldSZ="0" newLineSize="0" systemDependentDataFileName="">
        <RecordFormat cobolRecordName="out-rec" distinguishFieldValue="">
          <FieldsGroup DependingOn="" Name="f-tables" Occurs="2">
            <FieldsGroup DependingOn="" Name="f-comp-1-item" Occurs="1"/>
            <FieldsGroup DependingOn="" Name="f-comp-2-item" Occurs="1"/>
            <FieldFormat Decimal="2" DependingOn="" Name="f-comp-3-item"
              Occurs="1" Packed="true" Size="11" Type="9" Value=""/>
          </FieldsGroup>
        </RecordFormat>
      </FileFormat>

       
    • Paweł Mączka

      Paweł Mączka - 2007-12-13

      There is something wrong with your copybook.

      Why there is no picture attribute in your copybook ? Does Cobol allow it ? What is the default picture / size / type then ?
      Have your comp-1 and comp-2 fields any size ?

      cobol2j uses cb2xml ( another SF project ) to parse copybook and it gives attached xml.
      There are items with length = 0. cobol2j treats cb2xml items w/o picture attribute as fields groups.

      <copybook filename="nobody.cpy">
          <item display-length="12" level="01" name="out-rec" position="1" storage-length="12">
              <item display-length="6" level="05" name="f-tables" occurs="2" position="1" storage-length="6">
                  <item display-length="0" level="10" name="f-comp-1-item" position="1" storage-length="0" usage="computational-1"/>
                  <item display-length="0" level="10" name="f-comp-2-item" position="1" storage-length="0" usage="computational-2"/>
                  <item display-length="11" level="10" name="f-comp-3-item" numeric="true" picture="s9(9)V99" position="1" scale="2" storage-length="6" usage="computational-3"/>
              </item>
          </item>
      </copybook>

       
    • Nobody/Anonymous

      Thanks, Paweł for looking at my problem.  Since comp-1 and comp-2 are float and double respectively, COBOL does not allow picture clause for these data type.  I guess, that is cb2xml's problem but I am wondering why no one has encountered this issue before.  Maybe it's Micro Focus COBOL on PC (that what I am using).

       
    • Paweł Mączka

      Paweł Mączka - 2007-12-17

      Could you please send me some test data with comp-1 and comp-2 type? I think I can easy implement it. I don't have an access to this kind of data.

       
    • Paweł Mączka

      Paweł Mączka - 2007-12-17

      I plan also post a bug to cb2xml but it is not required to read data. cobol2j uses cb2xml only to parse copybook and create it own data format definition.

       
    • Trung Nguyen

      Trung Nguyen - 2007-12-18

      Hi Paweł,

      I can send you the copybook and the test data.  How do I send them to you?  I only have a few records for testing but I can create more if needed. 

       
    • Paweł Mączka

      Paweł Mączka - 2007-12-18

      copybook & few records for testing will be ok for me. Please also include real numbers to let me understand the representation. Just for one comp-1 and one comp-2 ... say in the first record. Please upload in new issue in "Feature Requests" tracker if you dont mind. Or send me by email by choosing me on "Project Admins : p4wciu" on sumary page.

      thank you for helping me to improve cobol2j!

      Paweł

       
    • Trung Nguyen

      Trung Nguyen - 2007-12-19

      Hi Paweł,

      I have crate a new "Feature Request" and attached the data file with it.  Please note that each record has 2 fields: f-comp-1 and f-comp-2.  Each record is 12 bytes (4 for comp-1 and 8 for comp-2).  The file size should be 36 bytes.

      data for record 1: 0,0
      data for record 2: +1, +1
      data for record 3: -1, -1

      Please let me know if you need more test data.

      Thanks,

      Trung 

       
    • Paweł Mączka

      Paweł Mączka - 2008-02-28

      1.4 contains new data types. Please test and let me know. thank you for your help.

      Paweł

       

Log in to post a comment.