Issues with nested cobol occurs

77 views
Skip to first unread message

Lee Brackman

unread,
Feb 9, 2015, 9:41:39 AM2/9/15
to legsta...@googlegroups.com
Below is a segment of my copybook that I am using to generate the java code from.  I have downloaded the latest 1.5.3 libraries running on JDK 1.7.

01 DFHCOMMAREA.
        05 ORDERUPDATE.
           10 INT-H0SEGID             PIC X(4). 
           10 INT-H0ORDCNT            PIC 9(5).
           10 INT-H001 OCCURS 99999 TIMES DEPENDING ON INT-H0ORDCNT.
              15 INT-H1SEGID          PIC X(4).
              15 INT-H1TRANSCNTR      PIC X(11).
              15 INT-H1CHGTYPE        PIC X(4).
              15 INT-H1WAYBILL        PIC X(10).
              15 INT-H1SHPMTID        PIC X(11).
              15 INT-H1DLVAGENT       PIC X(7).
              15 INT-H1CONSNAME       PIC X(30).
              15 INT-H1CONSADR1       PIC X(30).
              15 INT-H1CONSADR2       PIC X(30).
              15 INT-H1CITY           PIC X(20).
              15 INT-H1STATE          PIC X(2).
              15 INT-H1ZIP            PIC X(6).
              15 INT-H1PRMYPHNO       PIC X(20).
              15 INT-H1ALTRPHNO       PIC X(20).
              15 INT-H1ALTREXTN       PIC X(5).
              15 INT-H1DLVTYP         PIC X(2).
              15 INT-SKURECCOUNT      PIC 9(3).
              15 INT-DTA OCCURS 999 TIMES DEPENDING ON INT-SKURECCOUNT.
                 25 INT-D1SEGID       PIC X(4).
                 25 INT-D1TRANSCNTR   PIC X(11).
                 25 INT-D1SEQNO       PIC X(4).
                 25 INT-D1SKUID       PIC X(15).
                 25 INT-D1SKUDESC     PIC X(35).
                 25 INT-D1QTY         PIC X(7).
                 25 INT-D1QTYUOM      PIC X(2).

When I run a test with a fixed length file feed that matches the above copybook, I receive the following error when it tries to parse through the int-dta section:

Unexpected error while working iDirect feed: Cannot locate counter INT-SKURECCOUNT
com.legstar.coxb.transform.HostTransformException: Cannot locate counter INT-SKURECCOUNT
at com.legstar.coxb.transform.AbstractHostToJavaTransformer.transform(AbstractHostToJavaTransformer.java:266)
at com.legstar.coxb.transform.AbstractHostToJavaTransformer.transform(AbstractHostToJavaTransformer.java:190)
at com.legstar.coxb.transform.AbstractHostToJavaTransformer.transform(AbstractHostToJavaTransformer.java:147)
at com.legstar.coxb.transform.AbstractHostToJavaTransformer.transform(AbstractHostToJavaTransformer.java:114)
at com.legstar.coxb.transform.AbstractHostToJavaTransformer.transform(AbstractHostToJavaTransformer.java:99)

I have downloaded the source to see if I can determine what may be causing the issue, but it appears that the code that is in the trunk of svn is a bit outdated from the 1.5.3 release.  When I get to the method in the debug for CComplexBinding.getCounterInChildren(ICobolComplexBinding parent, String cobolName) the source doesn't matchup with the runtime.  From the source, it appears that it should be finding the skureccount element but I can't confirm that it is executing the line since the line numbers do not match.  I need either 1 of 2 things:  1) should the 1.5.3 release handing nested occurs and if so, is there something wrong with the copybook that it cannot find the depending field or 2) where can I get the 1.6 build  in order to step through the code and determine what it happening in the source to get it working appropriately (I tried to download the code and run maven locally, but there were junit test failing and api doc creations failing and I gave up, I will be willing to run the build myself if someone can provide me with build setup instructions so I can successfully do so)?

Thanks for your help!

Fady

unread,
Feb 9, 2015, 10:21:13 AM2/9/15
to legsta...@googlegroups.com
Hello,

If you are using maven, you should be able to include this dependency:

    <dependency>
       
<groupId>com.legsem.legstar</groupId>
       
<artifactId>legstar-core</artifactId>
       
<version>1.5.10</version>
   
</dependency>


    
Maven should get you the source code that matches.

If you are reading data from a file, then legstar-core should be the only module you need.

When you get legstar from SVN, you get all the modules, some of which are hard to build.

Fady

Fady

unread,
Feb 9, 2015, 10:36:01 AM2/9/15
to legsta...@googlegroups.com
Sorry, I meant;

    <dependency>
       
<groupId>com.legsem.legstar</groupId>
       
<artifactId>legstar-coxbrt</artifactId>
       
<version>1.5.10</version>
   
</dependency>

Lee Brackman

unread,
Feb 9, 2015, 1:28:03 PM2/9/15
to legsta...@googlegroups.com
Thank you.  I have the correct source version and this is what I see.  Using the copybook that I posted previously the java generator is creating a wrapper object for the occurs sequence, however the object being created is of type CArrayComplexBinding which from what I can see is not a type of ICobolComplexBinding.  Because of this it is not traversing the children elements of the H001 objects to look for the depends element of that nested occurs object.  I have tried to force it into thinking that there are complex objects in the parent but I can't seem to do so.  My last attempt was with the following copybook:

01 DFHCOMMAREA.
        05 ORDERUPDATE.
           10 INT-H0SEGID             PIC X(4). 
           10 INT-H0ORDCNT            PIC 9(5).
           10 INT-H001 OCCURS 99999 TIMES DEPENDING ON INT-H0ORDCNT.
              15 ORDERUPDATEENTRY. 
            20 INT-H1SEGID          PIC X(4).
            20 INT-H1TRANSCNTR      PIC X(11).
            20 INT-H1CHGTYPE        PIC X(4).
            20 INT-H1WAYBILL        PIC X(10).
            20 INT-H1SHPMTID        PIC X(11).
            20 INT-H1DLVAGENT       PIC X(7).
            20 INT-H1CONSNAME       PIC X(30).
            20 INT-H1CONSADR1       PIC X(30).
            20 INT-H1CONSADR2       PIC X(30).
            20 INT-H1CITY           PIC X(25).
            20 INT-H1STATE          PIC X(2).
            20 INT-H1ZIP            PIC X(6).
            20 INT-H1PRMYPHNO       PIC X(25).
            20 INT-H1ALTRPHNO       PIC X(25).
            20 INT-H1ALTREXTN       PIC X(5).
            20 INT-H1DLVTYP         PIC X(2).
            20 INT-SKURECCOUNT      PIC 9(3).
            20 INT-DTA OCCURS 999 TIMES DEPENDING ON INT-SKURECCOUNT.
               25 SKUENTRY.
              30 INT-D1SEGID       PIC X(4).
              30 INT-D1TRANSCNTR   PIC X(11).
              30 INT-D1SEQNO       PIC X(4).
              30 INT-D1SKUID       PIC X(15).
              30 INT-D1SKUDESC     PIC X(35).
              30 INT-D1QTY         PIC X(7).
              30 INT-D1QTYUOM      PIC X(2).

It generated the classes as I expected, but for some reason it didn't see the new complex object types at the time of traversal.

Fady

unread,
Feb 9, 2015, 2:21:04 PM2/9/15
to legsta...@googlegroups.com
You are close. I tried your copybook and confirm legstar does not handle this case properly.

There are at least 2 issues:

The first one is that the generated DfhcommareaBinding gets a negative BYTE_LENGTH.

The second is the bug you are hitting where legstar does not look for ODO counters within arrays. This is similar to the https://code.google.com/p/legstar/issues/detail?id=186 issue that was opened recently.

Unfortunately, I don't have much time to look into this before the end of the week. 

I would recommend you wait for a fix, but if you can't wait, the bug is around line 193 in CComplexBinding. It should look for ODO counters in arrays and choices, not only complex types.

Fady

Lee Brackman

unread,
Feb 10, 2015, 11:32:21 AM2/10/15
to legsta...@googlegroups.com
Thanks.  I was able to alter the logic to include the repeating arrays and it processed as I expected.  

I would at this time like to suggest an enhancement to your library that I think would be extremely beneficial.  For you source generation, can you provide a way for the end user to configure a super class that the generated classes would inherit from in order to implement patterns such as the visitor pattern?  There are some JAXB code generators that allow this and it would be a good addition to this library.

Thanks again for your quick response and feedback. 

Fady

unread,
Feb 14, 2015, 3:17:37 AM2/14/15
to legsta...@googlegroups.com
I have released legstar-core 1.6.0 with the fix to your issue (reported here: https://code.google.com/p/legstar/issues/detail?id=187)

You can get the new release from Maven central:

  <dependency>
     
<groupId>com.legsem.legstar</groupId>
     
<artifactId>legstar-coxbrt</artifactId>

     
<version>1.6.0</version>
 
</dependency>


  
As for the superClass suggestion you are making, I assume this is something similar to https://jaxb.java.net/nonav/2.1.14/docs/vendorCustomizations.html#superclass. I have opened an issue for that here: https://code.google.com/p/legstar/issues/detail?id=189 please feel free to further describe your need in that issue. Not an easy thing to do though because the generated classes already extend classes. Might be easier to achieve in the new legstar-core2.

Fady
Reply all
Reply to author
Forward
0 new messages