Menu

Open questions

dubwai
2006-12-14
2013-04-25
  • dubwai

    dubwai - 2006-12-14

    I am going to post some questions about copybooks here and if anyone can help me out, I will really appreciate it.

    My first question is about the picture clause.  In the CB2XML code, they have a case for 'G' but I can't find anything about this code.  Does anyone know what a G in a picture clause means?

    thanks,

     
    • Wouter Boussemaere

      The 'G' in a picture clause means that they want to access a GRAPHIC or VARGRAPHIC column in DB2. This is the case when you stored UTF-16 characters in a DBCS-column in DB2.

      byte count of GRAPHIC(n) = 2n
      byte count of VARGRAPHIC(n) = 2n + 2 -> first 2 bytes are used for length

      There are some extra resources on the IBM site on this (http://publib.boulder.ibm.com/infocenter/pdthelp/v1r1/index.jsp)
      Go through to Enterprise COBOL for z/OS -> Language Reference -> Data division -> data description entry -> PICTURE clause...

      Note: there are 2 special registers for PIC G (SHIFT-OUT and SHIFT-IN). You can find this by entering following search statement: PIC G and selecting the second result.

      Hope this helps...

      \Wouter

       
      • dubwai

        dubwai - 2007-01-18

        Thanks, for the help.

        Since you are the first person to post here, have you downloaded and used this tool?

        I'm looking for feedback.  Problems or even just complaints.  I'm working on some API improvements and I'm writing a basic gui app to help with creating and verifying tests.  Doing this has made me re-assess some decisions.  If anyone has any other suggestions or questions, please let me know.

        I see people are downloading this.  Please, tell me what you think.  I know the lack of documentation is a problem.  I'm just trying to get the basic functionality in.

         
    • Wouter Boussemaere

      Hi,

      I'll give some more background on this.

      I actually downloaded and I'm trying to use it to start COBOL submodules from WAS J2EE Applications using Java-native on z/OS and JNI. The CB2Java has been very helpful in converting the EBCDIC values to ASCII values in the copytexts.

      I actually found a small bug in the CB2Java-library.
      net.sf.cb2java.copybook.AlphaNumeric constructor

                  } else {
                      buffer.append(forChar(c));
                  }
              }
              // add - tn91779
              if (buffer.indexOf("{") < 0) {
                  buffer.append("{1}");
                  length += 1;
              }
              // end add - tn91779       

              this.pattern = Pattern.compile(buffer.toString());

      If a PIC X field was inserted in a copytext then the length wasn't augmented by 1.

      Something else is if the last field eg. PIC X(45) is not filled with characters by with zeroes (LOW-VALUES) the CopyBook.parseData fails... I think it has something to do with the Regexp-pattern which doesn't fit the data (LOW-VALUES).

      But it is a very good initiative.
      Keep up the good works.

      If you need some extra input please do contact me.

      Kr,
      \Wouter

       
      • Wouter Boussemaere

        I've fixed the LOW-VALUES myself by adding \000 to the regular expressions for AlphaNumeric

            private String forChar(char c)
            {
                switch (c) {
                case 'A':
                    return "[a-zA-Z \000]";
                case 'X':
                    return "[a-zA-Z0-9 \000]";
                case '9':
                    return "[0-9 \000]";
                default:
                    throw new IllegalArgumentException();
                }
            }

         
        • dubwai

          dubwai - 2007-01-23

          The whole values thing is kind of weak right now.  What you are saying here makes sense, although, should I accept low values through the API or just from the files?  If the item is set to a value of low values and the item is set all spaces, should I write low values?  I'm not really sure how the values thing is supposed to work.  If you have any ideas on how to approach this, I'd appreciate it.

          thanks.

           
          • Wouter Boussemaere

            I'm not completely sure what you mean here with item.

            I think if the Java programmer sets an item then the represented values in the data byte[] should be the value the programmer set and if the value doesn't fill the complete field then the item should be padded either by LOW-VALUES (with is the default) or by SPACES if the PIC clause mentions the VALUES SPACES clause (but of this I'm not sure if this should be the default behaviour, I'll ask around for this).

            In my example I have a byte[] from mainframecobol where the copytext looks like this:
                   01 NK14GP07.
                       02 IMPORT-EXPORT.
                          03 DEBUG-FLG         PIC X(01).
                          03 RETURN-GRP.
                             05 RETURN-CD      PIC X(01).
                             05 ERROR-CODE     PIC X(03).
                          03 CUST-ORD-DNR      PIC S9(9) COMP.
                          03 STT-PRCS-DNR      PIC S9(9) COMP.
                          03 SNR               PIC S9(4) COMP.
                          03 FINAL-FLG         PIC X(01).
                       02 FILLER               PIC X(45).

            And the data is as follows:
                    byte[] data = { (byte) 0xD5, (byte) 0x40, (byte) 0x40, (byte) 0x40, (byte) 0x40, (byte) 0x00, (byte) 0x09, (byte) 0xE8, (byte) 0x3A, (byte) 0x00, (byte) 0x00, (byte) 0x06, (byte) 0x43, (byte) 0x00, (byte) 0x01, (byte) 0xD5, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };

            As you see the last 45 databytes are zero bytes (in COBOL = LOW-VALUES) and that caused the problem for me. If I replaced it by (byte) 0x40 than it worked.

             
            • dubwai

              dubwai - 2007-01-25

              "I'm not completely sure what you mean here with item. "

              Good point.  I should try to be more precise with terminology especially since I there is an Item class.  What I meant was the data value for a single element.  I you assumed this is what I meant.

              OK, I've always thought that the item should be padded with spaces.  Maybe this is because we had problems with a flat-file reader at a previous job that was treating the a low value as a String terminator.  For this reason the files sent to us could never contain low-values except at the end of the record.

              If you do determine that the correct behavior is to pad with low-values, let me know and I will incorporate that into the code.  Eventually a lot of options are probably going to have to be supported given the varying implementations of COBOL that exist.

              Anyway, watch out or I'll ask you to join the project as a developer : )

               
      • dubwai

        dubwai - 2007-01-23

        Great catch on the length.  After thinking about it, I think it's a more far reaching bug than just for one element pics.  If I'm not mistaken, the issue will affect any pic element that isn't followed by (number).

        This is exactly the kind of thing I am looking for.  Thanks.  I'm glad you spotted the encoding setting.  I realized this was needed for binary and float types.  Speaking of float types, do you see needing comp-1 or comp-2 types ever?  I've added them in my current version.

        I'm also making some incompatible API changes.  I hope this won't cause too much trouble but some of the names were confusing.  Let me know if you think this is a bad idea.

         
        • Wouter Boussemaere

          I searched our CobolCopy texts and I haven't found any comp-1 or comp-2. So we don't need it obviously. But for completeness you can consider to implement it in a later stage I guess.

          As the project is still in pre-alpha and you are the developer of it, I can't have any objections to API changes, even if they are incompatible. :-D

          But some documentation on the changes would be very handy...

           
    • Asif

      Asif - 2007-02-08

      I have a very basic question regarding running the provided jar, I assume double clicking it should run the tool but it gives "Failed to load Main-class attribute from" the jar. Can you let me know how to run this?

       
      • dubwai

        dubwai - 2007-02-09

        CB2Java is a not an executable jar that can be run through double clicking.

        This library is not intended to be a stand alone program.  It is for use as a building block in other Java applications.

        If you are looking for a standalone GUI for viewing and editing files, you might want to check out the Record-Editor project here: http://sourceforge.net/projects/record-editor

        If you have questions about using CB2Java in a Java application, please feel free to start a new thread on these forums.

         
    • Nobodyman

      Nobodyman - 2007-04-10

      I'm having trouble generating an output datafile based on a copybook specification.

      In summary, what I'm trying to do is go convert the rows of a jdbc resultset to Copybook records,  and then write the records to an output file.  The problem is that record.toString()  seems to be trimming the blanks, and thus my recordlength is not is incorrect.

      I know that my copybook is being parsed correctly, and that I am succesfully writing values to my "leaf" fields in the copybook record.   I'm just unable to do the last step, that is, actually write the record to a file.

      Any advice on what I'm doing wrong? 

       
      • dubwai

        dubwai - 2007-04-13

        I'm not sure what it is exactly that you are doing, but you should not be calling toString() to write your data to output.  The method that you want to use is Record.write(OutputStream).

        There are a couple reasons why you don't want to get involved with Strings and application data.  It probably isn't something that you are worried about now, but if you ever want to use binary data or some other non-character data, you'll get into trouble when you go from one character set to another which is guaranteed on any non-ascii or unicode OS when you are working with Java.  I originally used Strings but I decided that it was too problematic.

        In any event try using the write method and if you are still running into trouble, post some code here.  I've been writing a quick-start tutorial but I've had a rough time at work lately and haven't had a chance to finish.

        If you have a minute, could you let me know what you think?  Did you run into any issues other than this?  Does cb2java behave the way you expect?

        thanks,

        -James

         

Log in to post a comment.

MongoDB Logo MongoDB