Menu

#16 Exception loading copybook with nested Occurs-Depending

v1.0_(example)
pending
None
1
2017-11-01
2016-09-10
Anonymous
No

I am seeing an error when loading a copybook with nested instances of 'occurs-depending'. Here is the copybook:

       01 ARRAY-COPYBOOK.
          03 NUM-PEOPLE            pic 9(12).
          03 PEOPLE occurs 0 to 3 times depending on NUM-PEOPLE.
             05 F-NAME             pic X(40).
             05 L-NAME             pic X(40).
             05 NUM-ID             pic 999.
             05 ID-X occurs 0 to 2 times depending on NUM-ID.
                10 ID              pic 99999.

This is the stack trace:

java.lang.RuntimeException: Error With Occurs Depending On Field: NUM-ID
        at net.sf.JRecord.External.Def.DependingOn.updateField(DependingOn.java:151)
        at net.sf.JRecord.External.Def.DependingOn.updateField(DependingOn.java:160)
        at net.sf.JRecord.Details.RecordDetail.setDependingOn(RecordDetail.java:1100)
        at net.sf.JRecord.External.ToLayoutDetail.toRecordDetail(ToLayoutDetail.java:178)
        at net.sf.JRecord.External.ToLayoutDetail.getLayout(ToLayoutDetail.java:81)
        at net.sf.JRecord.External.CopybookLoaderFactory.getLayout(CopybookLoaderFactory.java:270)
        at OccursDependingTest.main(OccursDependingTest.java:11)

And the program doing the loading:

import net.sf.JRecord.Details.LayoutDetail;
import net.sf.JRecord.External.CopybookLoaderFactory;
import net.sf.JRecord.Log.TextLog;

public class OccursDependingTest {

    public static void main(String[] args) {
        String copybookFileName = "NestedOccursDepending.cbl";
        CopybookLoaderFactory f = CopybookLoaderFactory.getInstance();
        try {
            LayoutDetail layout =(f.getLayout(CopybookLoaderFactory.COBOL_LOADER, copybookFileName, 0, "CP037", 0, new TextLog()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

This is with version 0.81.1. Here is a similar issue from a while back which might be related: https://sourceforge.net/p/jrecord/bugs/14/.

Discussion

  • Anonymous

    Anonymous - 2016-09-10

    The issue might be that the second 'occurs-depending' field depends on a field that isn't at the 03 level. If I change the copybook to

           01 ARRAY-COPYBOOK.
              03 NUM-PEOPLE            pic 9(12).
              03 NUM-ID                pic 999.
              03 PEOPLE occurs 0 to 3 times depending on NUM-PEOPLE.
                 05 F-NAME             pic X(40).
                 05 L-NAME             pic X(40).
                 05 ID-X occurs 0 to 2 times depending on NUM-ID.
                    10 ID              pic 99999.
    

    it loads fine.

     
  • Bruce Martin

    Bruce Martin - 2016-09-10
    • assigned_to: Bruce Martin
     
    • Bruce Martin

      Bruce Martin - 2016-09-10

      The problem is definitely with NUM-ID being part of the array. It is looking a plain field called
      NUM-ID, not an array-field NUM-ID (Array-Index).

      Unfortunatly there is no easy way to change this. The depending on fields can not be part of the parent array.

      How essential is this ??? because it will be a lot of work to handle ???

       
      • John

        John - 2016-09-11

        Thanks for taking a look at this. Unfotunately, I am writing an application which is intended to handle arbitrary copybooks, so I just won't be able to handle ones like that.

         
        • Bruce Martin

          Bruce Martin - 2016-09-11

          I suspect that:

          • Earlier versions of the Cobol standard did not allow it, individual Cobol implementations may implement it as a standard.
          • It is fairly rare
           
        • Bruce Martin

          Bruce Martin - 2016-09-11

          I posted the original Copybook in a Cobol Forum:

             01 ARRAY-COPYBOOK.
                03 NUM-PEOPLE            pic 9(12).
                03 PEOPLE occurs 0 to 3 times depending on NUM-PEOPLE.
                   05 F-NAME             pic X(40).
                   05 L-NAME             pic X(40).
                   05 NUM-ID             pic 999.
                   05 ID-X occurs 0 to 2 times depending on NUM-ID.
                      10 ID              pic 99999.
          

          The nesting NUM-ID in a Occurs depending array is not supported by IBM Cobol:

           7  IGYGR1106-W   The "OCCURS DEPENDING ON" object "NUM-PEOPLE" was defined with more than 9 digits.  Only the rightmost 9 digits will be used in the length calculations.
          
          11  IGYGR1263-S   "OCCURS DEPENDING ON" object "NUM-ID" was defined as a table element.  The "DEPENDING ON" phrase was discarded.
          
          11  IGYGR1116-S   The "DEPENDING ON" object for table "ID-X" was invalid.  The "DEPENDING ON" phrase was discarded.
          

          Some thought Microfocus Cobol might support this

          IBM Cobol requires occurs depending field to be in a Fixed position. Even the nested occurs depending started as an IBM extension to the standard Cobol

           
        • Bruce Martin

          Bruce Martin - 2016-10-04

          John, I have started work on supporting Complex Occurs Depending, there is a new version of JRecord:

          This should work with the last Cobol2Xml:

          I have done some testing on 2 level Complex OD but not 3 level OD (yet).

          It would be useful If some one could check check against real Live files as I do not have any. There are more changes and Testing before I do a full release of the JRecord. Probably a couple of weeks

           
  • Bruce Martin

    Bruce Martin - 2016-09-10

    Will look at.

     
  • Bruce Martin

    Bruce Martin - 2016-10-16

    I have now added support for nested Occurs Depending:

     
  • Bruce Martin

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

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB