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).
Anonymous
Diff:
Will look at it
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
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
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.
Is there redefines in redefines or some other complication ???
No, it seems to be the same thing where a redefine is not explicitally declaring the entire size of the redefined level.
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:
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
I think I have found the issue, I fixed it when it was a redefine at the highest level.
e.g.
but not when the redefines at a lower level e.g.
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
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
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.
Out of curiousity, when do you think this will be added to an official JRecord release?
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.
This has been fixed
Is it now included in a versioned release?
Last edit: Lee Shaffer 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