Menu

#24 Cobol copybook - Certain field conversions not happening correctly with RecordEditor

v1.0_(example)
open
None
1
2021-02-15
2018-08-23
Mandy P
No

i am using a Cobol copybook to retrive data from an EBCIDIC file . prolem is some of the fields especiallythose with names begining with NULLIF_...... do not convert correctly . Is there something I m doing wrong. Attaching the Copybook for reference..

1 Attachments

Related

Bugs: #24

Discussion

  • Bruce Martin

    Bruce Martin - 2018-08-23

    Can you provide the Java / sample file. Also where is the file coming from ??? is it an IBM mainframe ???.

    I will try and send you a message with my E-mail in case the data is sensitive

     
    • Mandy P

      Mandy P - 2018-08-23

      Hi,
      I am using the RecordEditor 's load Cobol Copy book option where I give as inputs the copybook file name & the EBCDIC file name. Data is sensitive.

      copy book file - tgen534 - Copy.cob
      EBCDIC data file - 0.NONFIN

      Actual expected output - 0.ASC

      thecode file generated - dsc.rar

      Thanks

      Screen shot of output in RecordEditor is -
      [cid:b4aba158-a865-45e3-98e4-9e8ecf153c5e]


      From: Bruce Martin bruce_a_martin@users.sourceforge.net
      Sent: Thursday, August 23, 2018 10:39 AM
      To: [jrecord:bugs]
      Subject: [jrecord:bugs] #24 Cobol copybook - Certain field conversions not happening correctly with RecordEditor

      Can you provide the Java / sample file. Also where is the file coming from ??? is it an IBM mainframe ???.

      I will try and send you a message with my E-mail in case the data is sensitive


      [bugs:#24]https://sourceforge.net/p/jrecord/bugs/24/ Cobol copybook - Certain field conversions not happening correctly with RecordEditor

      Status: open
      Group: v1.0_(example)
      Created: Thu Aug 23, 2018 09:16 AM UTC by Mandy P
      Last Updated: Thu Aug 23, 2018 09:17 AM UTC
      Owner: nobody
      Attachments:

      i am using a Cobol copybook to retrive data from an EBCIDIC file . prolem is some of the fields especiallythose with names begining with NULLIF_...... do not convert correctly . Is there something I m doing wrong. Attaching the Copybook for reference..


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/jrecord/bugs/24/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #24

  • Bruce Martin

    Bruce Martin - 2018-08-26

    The -1 is because of the s9 comp if you change to 9 Comp you will get 255. The s indicates sign. This dialect was set up for GNU-Cobol

    What do I do if I want to run this off the console or then may be put it as crond , say supply an input file name or directory

    • You can pass the file names in using arguments on java main. All the IOBuilder methos accept FileNames etc
     
    • Mandy P

      Mandy P - 2018-08-27

      Hi
      The auto-generated java code from report-writer shows the following error on compiling, what could be the problem -

      javac -Xdiags:verbose ReadTgen534Copy.java

      ReadTgen534Copy.java:70: error: method setDialect in interface ICobolIOBuilder cannot be applied to given types;
      .setDialect("ICopybookDialects.FMT_GNU_COBOL"
      )
      ^
      required: int
      found: String
      reason: argument mismatch; String cannot be converted to int
      1 error

      ==============
      Java code -
      ==============
      import net.sf.JRecord.JRecordInterface1;
      import net.sf.JRecord.Details.AbstractLine;
      import net.sf.JRecord.IO.AbstractLineReader;
      import net.sf.JRecord.Common.Constants;
      import net.sf.JRecord.External.CopybookLoader;
      import net.sf.JRecord.def.IO.builders.ICobolIOBuilder;

      import dsc.schema.FieldNamesTgen534Copy;

      /*
      * Read Cobol file using a Cobol Copybook (Tgen534Copy).
      *
      * This Generated program is intended as an example of using JRecord
      * rather than a useful program (that compiles - it wont).
      * You should regard it as a starting point and modify
      * it according to needs
      /
      public final class ReadTgen534Copy {

      private String dataFile     = "C:/download/pawan/kadi/0.NONFIN";
      private String copybookName = "C:/download/pawan/kadi/tgen534 - Copy.cob";
      
      /**
       * Example of LineReader  classes
       */
      public ReadTgen534Copy() {
          super();
      
          AbstractLine line;
          int lineNum = 0;
      
          try {
              ICobolIOBuilder iob = JRecordInterface1.COBOL
                                  .newIOBuilder(copybookName)
                                     .setDialect("ICopybookDialects.FMT_GNU_COBOL")
                                     .setFont("cp037")
                                     .setFileOrganization(Constants.IO_FIXED_LENGTH)
                                     .setSplitCopybook(CopybookLoader.SPLIT_NONE)
                                         ;
      
              FieldNamesTgen534Copy.RecordTgen534Copy rTgen534Copy = FieldNamesTgen534Copy.RECORD_TGEN534___COPY;
              AbstractLineReader reader = iob.newReader(dataFile);
              while ((line = reader.read()) != null) {
                  lineNum += 1;
                  System.out.println(
                                line.getFieldValue(rTgen534Copy.itnIdnCde).asString()
                        + " " + line.getFieldValue(rTgen534Copy.mhtItlNbr).asString()
                        + " " + line.getFieldValue(rTgen534Copy.mhtExtTxt).asString()
                        + " " + line.getFieldValue(rTgen534Copy.nullifCnyMhtIdnTxt).asString()
                        + " " + line.getFieldValue(rTgen534Copy.cnyMhtIdnTxt).asString()
                        + " " + line.getFieldValue(rTgen534Copy.mhtNmeTxt).asString()
                        + " " + line.getFieldValue(rTgen534Copy.nullifLngMhtNmeTxt).asString()
                        + " " + line.getFieldValue(rTgen534Copy.lngMhtNmeTxt).asString()
                        + " " + line.getFieldValue(rTgen534Copy.extMccCde).asString()
                        + " " + line.getFieldValue(rTgen534Copy.mhtTypCde).asString()
                        + " " + line.getFieldValue(rTgen534Copy.lcnCttTypCde).asString()
                     );
              }
      
              reader.close();
          } catch (Exception e) {
              System.out.println("~~> " + lineNum + " " + e);
              System.out.println();
      
              e.printStackTrace();
          }
      }
      
      public static void main(String[] args) {
          new ReadTgen534Copy();
      }
      

      }


      From: Bruce Martin bruce_a_martin@users.sourceforge.net
      Sent: Sunday, August 26, 2018 12:56 AM
      To: [jrecord:bugs]
      Subject: [jrecord:bugs] #24 Cobol copybook - Certain field conversions not happening correctly with RecordEditor

      The -1 is because of the s9 comp if you change to 9 Comp you will get 255. The s indicates sign. This dialect was set up for GNU-Cobol

      What do I do if I want to run this off the console or then may be put it as crond , say supply an input file name or directory

      • You can pass the file names in using arguments on java main. All the IOBuilder methos accept FileNames etc

      [bugs:#24]https://sourceforge.net/p/jrecord/bugs/24/ Cobol copybook - Certain field conversions not happening correctly with RecordEditor

      Status: open
      Group: v1.0_(example)
      Created: Thu Aug 23, 2018 09:16 AM UTC by Mandy P
      Last Updated: Thu Aug 23, 2018 02:15 PM UTC
      Owner: nobody
      Attachments:

      i am using a Cobol copybook to retrive data from an EBCIDIC file . prolem is some of the fields especiallythose with names begining with NULLIF_...... do not convert correctly . Is there something I m doing wrong. Attaching the Copybook for reference..


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/jrecord/bugs/24/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #24

  • Bruce Martin

    Bruce Martin - 2018-08-27

    In the short term remove the quotes if you have not already done so, I will fix the skelton

     
    • Mandy P

      Mandy P - 2018-08-28

      Yeah, that was done. it says unknown variable ,. replaced it with values of 0 then 1 then 2 but output is not as it should be., Report- editor shows the resuts correctly , so should n't this

       
      • Bruce Martin

        Bruce Martin - 2018-08-28

        try importing

        import net.sf.JRecord.Numeric.ICopybookDialects;
        

        There are javadocs explanations for all the methods

         
        • Mandy P

          Mandy P - 2018-08-28

          Yes , it works. Had missed it. Does this project have a facility to do Conversion without creating the Conversion code, guess that is what RecordEditor does. Where do we find the code for this
          Thanks


          From: Bruce Martin bruce_a_martin@users.sourceforge.net
          Sent: Tuesday, August 28, 2018 5:58 AM
          To: [jrecord:bugs]
          Subject: [jrecord:bugs] Re: #24 Cobol copybook - Certain field conversions not happening correctly with RecordEditor

          try importing

          import net.sf.JRecord.Numeric.ICopybookDialects;

          There are javadocs explanations for all the methods


          [bugs:#24]https://sourceforge.net/p/jrecord/bugs/24/ Cobol copybook - Certain field conversions not happening correctly with RecordEditor

          Status: open
          Group: v1.0_(example)
          Created: Thu Aug 23, 2018 09:16 AM UTC by Mandy P
          Last Updated: Tue Aug 28, 2018 02:54 AM UTC
          Owner: nobody
          Attachments:

          i am using a Cobol copybook to retrive data from an EBCIDIC file . prolem is some of the fields especiallythose with names begining with NULLIF_...... do not convert correctly . Is there something I m doing wrong. Attaching the Copybook for reference..


          Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/jrecord/bugs/24/

          To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

           

          Related

          Bugs: #24

          • Bruce Martin

            Bruce Martin - 2018-08-28

            The RecordEditor does the GUI based Conversion:

            Source code for the RecordEditor:

            https://sourceforge.net/p/record-editor/code/HEAD/tree/Source/

             
  • Mandy P

    Mandy P - 2018-08-28

    say in a line of code like - line.getFieldValue("ITN-IDN-CDE").asString()

    ls ".asString( )" the method to handle Text , COMP & COMP-3 ? or do we have something else for COMP, COMP3 ?

     
  • Bruce Martin

    Bruce Martin - 2018-08-29
    • assigned_to: Bruce Martin
     
    • Mandy P

      Mandy P - 2018-08-30

      I have the ascii converted dump given to me from some other utility (which does it accurately), one of the difference noted, for example is - that a field NULLIF_LNG-MHT-NME-TXT gets translated in JRecord as 0 where as the actual data is 0000 . Any idea why this is happening ? any way to deal with it ? in the copy book this field is specified as PIC 9 USAGE COMP
      Attaching the ASCII file 0.ASC for reference for the same data.

      one more instance is LCN-CTT-IDN-NBR PIC S9(9) USAGE COMP JRecord shows it as 45731 however it should be 000045731


      From: Bruce Martin bruce_a_martin@users.sourceforge.net
      Sent: Wednesday, August 29, 2018 2:11 PM
      To: [jrecord:bugs]
      Subject: [jrecord:bugs] #24 Cobol copybook - Certain field conversions not happening correctly with RecordEditor

      • assigned_to: Bruce Martin
      • Comment:

      You can use any of the as... methods at any time, JRecord will try and do the conversion for you.
      You can do asInt on a Text field; JRecord will try and convert it to an integer. If field contins non numeric Data you will have a problem.

      For a pic s9(4)V9(4) you may want to convert it to either a Double or BigDecimal


      [bugs:#24]https://sourceforge.net/p/jrecord/bugs/24/ Cobol copybook - Certain field conversions not happening correctly with RecordEditor

      Status: open
      Group: v1.0_(example)
      Created: Thu Aug 23, 2018 09:16 AM UTC by Mandy P
      Last Updated: Tue Aug 28, 2018 01:51 PM UTC
      Owner: Bruce Martin
      Attachments:

      i am using a Cobol copybook to retrive data from an EBCIDIC file . prolem is some of the fields especiallythose with names begining with NULLIF_...... do not convert correctly . Is there something I m doing wrong. Attaching the Copybook for reference..


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/jrecord/bugs/24/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #24

      • Bruce Martin

        Bruce Martin - 2018-08-30

        Neither answers are wrong they a different packages and do thingd differently.

        you will find 0 == 0000 gives True and 45731 == 000045731 as well

        In Cobol Pic 9 means 1 digit numeric number, I see printing it as 0000 as a strange idosyncroncy of your exising package.

        While PIC S9(9) means an integer of maximum length of 9.

         
  • Bruce Martin

    Bruce Martin - 2018-08-29

    You can use any of the as... methods at any time, JRecord will try and do the conversion for you.
    You can do asInt on a Text field; JRecord will try and convert it to an integer. If field contins non numeric Data you will have a problem.

    For a pic s9(4)V9(4) you may want to convert it to either a Double or BigDecimal

     

Anonymous
Anonymous

Add attachments
Cancel