Occurs-Depending bug on last field
Read Cobol data files in Java
Status: Beta
Brought to you by:
bruce_a_martin
I'm get an 'Error calculation Occurs Depending On' error when trying to use the following copybook (slightly modified from the tests):
01 Location-Details. 03 Record-Type pic x. 03 Level-Count pic s99. 03 Attr-count pic s99. 03 Location-Levels. 05 occurs 1 to 5 depending on Level-Count. 10 Level pic 999. 10 occurs 1 to 5 depending on Attr-count. 15 Attr pic 99.
Adding the following two lines to the end of the file fixes the issue so it seems to be a problem with the 'occurs-depending' field being the only one and also being in the final group in the copybook.
05 occurs 1 to 5 depending on Attr-count. 10 Attribute pic 99.
Unfortunately I don't have control over the copybooks I'm using so can't use the above workaround, but hopefully this will help to resolve the issue. I understand the 'occurs-depending' feature is not production-ready but is there another way to fix this issue?
Thanks
Anonymous
Are you using the copybook for reading or writing ???,
also the full stack trace would be usefull
Last edit: Bruce Martin 2015-11-04
I have just tested the copybook with my Source code and can not see a problem with processing it.
I have just updated subversion with latest code.
Can you download the latest source and get a Stack Trace. The error could be caused by a array size being invalid / not set.
Hey Bruce -
I saw an occurs-depending error and thought this was a good place to chime in. This could still be something I'm doing wrong but I wanted to see if you could have a look at it.
This is my copybook:
The error I'm seeing appears to be related to the "depends on" count being a COMP field - when I remove the COMP
(which obviously doesn't work, but I wanted to see) the process fail normally. When I run it as-is, I get a NegativeArraySizeException
from the ContinuousLineReader. Can you recommend a change I can make that will allow this to process? We have other occurs-depending files
that are working right now with no problem. That COMP seems to be the 'X' factor...
Anything you can tell me will be a huge help. As always - JRecord is hugely important to my operations here and I bless you every day for writing it so I didn't have to. Thank you for your hard work!
Last edit: Michael Zoghby 2019-05-10
I will look at it
I have had look, at my version of JRecord; everything looks to be working.
I would suggest double checking everything (if you have not already). In particular
I am also happy to look at the file / copybook to see the problem. - Do you have my e-mail address ???
Thank you for responding so quickly! I realized I didn't even post the version I'm using - 0.81.4:
I have attached the copybook and very small (9 kb) sample file I have in my possession. It's possible I simply need to upgrade my JRecord version but I read that 0.90 was a pretty huge departure from previous versions and our application uses a good number of the detailed tools present in JRecord - I was concerned about the disruption of a big upgrade.
I don't have your email address but I'm happy to switch to email if that's easier than working here.
In your code you have
Continuous vs VB Dump
With IO_CONTINOUS_NO_LINE_MARKER you are expecting
what you have is
<block length=""><record length=""><line 1=""><record length=""><line 2=""> ... <block length=""><record length=""><line n=""></line></record></block></line></record></line></record></block>
So when JRecord looks for the array count, it looks in the wrong place (it is looking in
DTLNK-CARD-ACCT-16-ID a character field).
It is actually a safer way to recieve files because you have the Mainframe Record-Lengths
RecordEditor
If you supply both a Cobol-Copybook and a Sample file to either the:
The RecordEditor will check for the various VB formats (it does not check for
IO_CONTINOUS_NO_LINE_MARKER though.
Layout Import:
Last edit: Bruce Martin 2019-05-13
So you're 100% correct on using the continuous line bit...
The issue is I'm also standing up a continuous line reader to read the file because it was the only thing that worked with my complex records.
I made the change you noted to
VB_IO_DUMP
fromIO_CONTINOUS_NO_LINE_MARKER
and am still seeing the same error as above (NegativeArraySize)JRecord version
0.81.4
:This is where I stand up my builders and copybook:
and later:
and I'm using the ExternalRecordSelector objects to allow my reads to work when I don't use the record decider:
and an example of the JSON I feed it to help it find the records:
This code works for every copybook I've every thrown at JRecord except this one with the COMP occurs-depending.
I know almost nothing about Mainframes - JRecord has literally saved my life the last year or so. I think I follow what you're saying about the record block length being
captured by the VB dump but I don't know what that means for the rest of my working code if I make more changes.
Problem:
Problem is you are hard coding the ContinuousLineReader
You will need some flag to indicate the type of Reader.
Possible Solution
This is one (of many) possible solution. Hopefully it will give you idea's
JSon
add a FileStructure Field i.e. something like:
setCopyBook
You do not need:
if you need the copyBook field you can do
Creating Reader
With regards JRecord 0.90 vs 0.84 I have tried to keep it backward
compatible as possible
Only change to 0.90 if you need something from version 0.90. But make sure you have
good test coverage in case you need to move.
So I think I understand - my problem was I was smashing all these different things together striving for a "read all comers" single solution. You're telling me this file is unique because it's a single record "dump" that is differently organized than the formats I'm use to - multiple 01 records in a copybook each with a "record type" and the layouts can be different lengths.
So - again, total COBOL/mainframe ignorance - is there a good way to tell just by looking at a copybook if it's a "dump" that the builder can just hand me a reader for versus a layout I need to configure selectors to read? I've attached a copybook example I would describe as my "usual" work.
Last edit: Michael Zoghby 2019-05-14
So I think I understand - my problem was I was smashing all these different things together striving for a "read all comers" single solution. You're telling me this file is unique because it's a single record "dump" that is differently organized than the formats I'm use to
So - again, total COBOL/mainframe ignorance - is there a good way to tell just by looking at a copybook if it's a "dump"
I have added a new a new wiki entry Mainframe File System
Other wikis
Last edit: Bruce Martin 2019-05-15