Menu

#13 Copybook not being loaded properly if redefine isn't defining the entire length

v1.0_(example)
closed
None
1
2017-11-01
2015-10-29
Lee Shaffer
No

As an example, we had a 27,000 byte copybook, but it was being read as 26,289. I can't reveal the copybook for privacy reasons, but I can give an example of why this was happening by using a below example.

05 Order-customer-gr
    10 order-customer occurs 5 times     pic x(35).

05 order-bank-gr redefines order-customer-gr.
    10 order-cust-line1        pic x(6).

05 order-party pic x(10).

The above can be considered bad programming practice, but we have no control over this copybook and can't change it. It is still valid though. Order-customer-gr occupies 175 bytes of space. The order-bank-gr redefines those 175 bytes, but only specifies 6 for order-cust-line1. Now, when jRecord goes to parse order-party, it includes it as order-bank-gr. It will keep adding variables to the same 175 byte definition space until it is filled up. This is what was causing the length to be wrong. and the positions would be off for any field beyond these.

For a test, I was able to modify the copybook to include filler to fill up the reamining 169 bytes in order-bank-gr and jRecord worked fine. However, this will not be possible in a prod environment. Is there any way to not have jRecord to continue to fill those remaining 169 bytes?

The fix I had to do locally to test was to add 169 bytes of filler as shown below:

05 order-bank-gr redefines order-customer-gr.
    10 order-cust-line1        pic x(6).
    10 filler                        pic x(169).

Discussion

  • Bruce Martin

    Bruce Martin - 2015-10-29
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,12 +1,13 @@
     As an example, we had a 27,000 byte copybook, but it was being read as 26,289. I can't reveal the copybook for privacy reasons, but I can give an example of why this was happening by using a below example.
    
    -05 Order-customer-gr
    -    10 order-customer occurs 5 times     pic x(35).
    +    :::Cobol
    +    05 Order-customer-gr
    +        10 order-customer occurs 5 times     pic x(35).
    
    -05 order-bank-gr redefines order-customer-gr.
    -    10 order-cust-line1        pic x(6).
    +    05 order-bank-gr redefines order-customer-gr.
    +        10 order-cust-line1        pic x(6).
    
    -05 order-party pic x(10).
    +    05 order-party pic x(10).
    
     The above can be considered bad programming practice, but we have no control over this copybook and can't change it. It is still valid though. Order-customer-gr occupies 175 bytes of space. The order-bank-gr redefines those 175 bytes, but only specifies 6 for order-cust-line1. Now, when jRecord goes to parse order-party, it includes it as order-bank-gr. It will keep adding variables to the same 175 byte definition space until it is filled up. This is what was causing the length to be wrong. and the positions would be off for any field beyond these. 
    
    @@ -15,6 +16,7 @@
    
     The fix I had to do locally to test was to add 169 bytes of filler as shown below:
    
    -05 order-bank-gr redefines order-customer-gr.
    -    10 order-cust-line1        pic x(6).
    -    10 filler                        pic x(169).
    +    :::Cobol
    +    05 order-bank-gr redefines order-customer-gr.
    +        10 order-cust-line1        pic x(6).
    +        10 filler                        pic x(169).
    
     
  • Bruce Martin

    Bruce Martin - 2015-10-29

    Will look at it

     
  • Bruce Martin

    Bruce Martin - 2015-10-30

    Please download a new cb2xml.jar from the cb2xml project and existing cb2xml.jar

    It will take time to flow through to a JRecord release

     

    Last edit: Bruce Martin 2015-11-08
  • Bruce Martin

    Bruce Martin - 2015-11-08

    I have a new version of cb2xml

    that has a fix for this issue, you can download a new cb2xml.jar from there to fix the issue

     
  • Lee Shaffer

    Lee Shaffer - 2015-11-16

    Tested it and still having the same issue. Reader object still had a lineLength of 26289 meaning it's not parsing the copybook properly. It should be 27000.Seems like it still has to do with when the copybook doesn't define the full redefined space.

     
  • Bruce Martin

    Bruce Martin - 2015-11-16

    Is there redefines in redefines or some other complication ???

     
  • Lee Shaffer

    Lee Shaffer - 2015-11-16

    No, it seems to be the same thing where a redefine is not explicitally declaring the entire size of the redefined level.

       10  ORDERING-INFORMATION.                             
             15  ORDER-CUSTOMER-GR.                            
                 20  ORDER-CUSTOMER                            
                   OCCURS 5 TIMES              PIC X(35).         
             15  FILLER REDEFINES ORDER-CUSTOMER-GR.           
                 20  ORD-CUST-LINE1         PIC X(06).         
                     88  ORD-CUST-TRAVEL-RULE                  
                         VALUE 'TEST'.       
             15  ORDER-BANK-GR.                                
                 20  ORDER-BANK                                
                   OCCURS 5 TIMES               PIC X(35).        
             15  ORDER-BANK-CUST-ID          PIC X(10).
    

    For example, you'll see there is a level 15 filler that redefines ORDER-CUSTOMER-GR. That is taking up 175 bytes(level 20 occurs 5 times for 35 bytes. 35 x 5 = 175). However, the level 15 filler that is redefining those 175 bytes is only defining 6 bytes. This leaves 169 bytes available to be defined in the redefined space(175 - 6 = 169).

    What ends up happening is that the fields following the level 15 filler redefine will be added into those 169 bytes. This throws off the position of the fields. So if ORDER-BANK-GR is supposed to be in position 200, it won't be because it's part of the redefined space.

    My theory was that since I saw it doing this, if I explicitally defined those 169 bytes under the level 15 filler, then it should be parsed correctly. This turned out to be true. I declared a level 20 filler of 169 bytes and then everything was parsed correctly and the positions all lined up.

    Fix example:

       10  ORDERING-INFORMATION.                             
             15  ORDER-CUSTOMER-GR.                            
                 20  ORDER-CUSTOMER                            
                   OCCURS 5 TIMES              PIC X(35).         
             15  FILLER REDEFINES :::ORDER-CUSTOMER-GR.           
                 20  ORD-CUST-LINE1         PIC X(06).         
                     88  ORD-CUST-TRAVEL-RULE                  
                         VALUE 'TEST'.       
                  20 FILLER                     PIC X(169). --What I added!!
             15  ORDER-BANK-GR.                                
                 20  ORDER-BANK                                
                   OCCURS 5 TIMES               PIC X(35).        
             15  ORDER-BANK-CUST-ID          PIC X(10).
    

    Does this make any sense? I tried debugging the code to figure out exactly where this was happening, but I hard a hard time following everything that is going on.

     

    Last edit: Bruce Martin 2015-11-17
  • Bruce Martin

    Bruce Martin - 2015-11-16

    I think I have found the issue, I fixed it when it was a redefine at the highest level.

    e.g.

          05   xxx.
          05   yyy redefines xxx.
    

    but not when the redefines at a lower level e.g.

          03  top-level.
              05  xxx.
              05  yyy redefines xxx.
    

    There needed to be a change in different place in the code.

    I have changed the program and I am currently testing the change. Also I am writing complicated
    redefines (e.g. multi-level; occurs etc).

    I should have a fix attached today.

     

    Last edit: Bruce Martin 2015-11-16
  • Bruce Martin

    Bruce Martin - 2015-11-17

    Sorry about fixing it properly the first time around; I have been busy lately, Lots of quetions, queries, problems across 4 different projects.

    I have attached the latest cb2xml.jar, I think the issue is now fixed now

    Please let me know how you go

     
    • Lee Shaffer

      Lee Shaffer - 2015-11-17

      No worries. Initial testing looks good and no issues so far. I'll continue testing and will let you know if I run into anything. The quick response is greatly appreciated.

       
  • Lee Shaffer

    Lee Shaffer - 2015-11-17

    Out of curiousity, when do you think this will be added to an official JRecord release?

     
  • Bruce Martin

    Bruce Martin - 2015-11-17

    At this stage I hope to get a new version out next week, it will be a bug fix release, no real changes to the library.

     
  • Bruce Martin

    Bruce Martin - 2016-01-04
    • status: open --> pending
     
  • Bruce Martin

    Bruce Martin - 2016-01-04

    This has been fixed

     
    • Lee Shaffer

      Lee Shaffer - 2016-01-13

      Is it now included in a versioned release?

       

      Last edit: Lee Shaffer 2016-01-13
  • Bruce Martin

    Bruce Martin - 2016-01-13

    Version 0.80.8h should (it has cb2xml 0.95.5). I should of updated the problemearlier on.

    Any way there will be a new release in the next day or 2 that will include it.

    Anyway 0.80.8i is out now...

     

    Last edit: Bruce Martin 2016-01-14
  • Bruce Martin

    Bruce Martin - 2017-11-01
    • status: pending --> closed
     

Anonymous
Anonymous

Add attachments
Cancel