Menu

Occurs

Help
2015-08-14
2015-08-18
  • Bernd Stoltefuss

    Hi again,

    another question:
    How do i address a field in an occurs section?

    My copybook is like this:

    01 BLA.
        02 REC.
            05 FIELD1         PIC X(10)
            05 GROUP1 OCCURS 10.
                10 FIELDX     PIC X(10).
                10 FIELDY     PIC X(20).
            05 GROUP2 OCCURS 20.
                10 FIELDY     PIC X(10).
                10 FIELDZ     PIC X(20):
    

    I tried
    layout.getGroupField("REC", "GROUP1 (1)", "FIELDX");
    and
    layout.getGroupField("REC", "GROUP1", "FIELDX (1)");

    But both versions don't seem to find the field. As i never worked with occurs fields before i am not sure about the correct way to get the fieldDetail espacially as i have to adress it with it's group name, as it may occur in more then one group in the copybook.

     

    Last edit: Bruce Martin 2015-08-14
  • Bernd Stoltefuss

    May be i found nd the solution by dumping the fieldDetail incl. GroupName.
    The correct way seems to be:
    layout.getGroupField("REC", "GROUP1 (1)", "FIELDX (1)");

    So the index has to be used on both group and field. Rather odd...

     
    • Bruce Martin

      Bruce Martin - 2015-08-18

      I have updated so that the following works:

      • layout.getGroupField("REC", "GROUP1", "FIELDX (1)");

      Also Group details are exported/imported in RecordEditor-Xml. They are exported as a Tag on the field item, but only when they change so you get

       <field ... group=".a.b.c.">
       <field ...>
       <field ...>
        <field ... group=".a.d.">
       <field ...>
      
       
  • Bruce Martin

    Bruce Martin - 2015-08-14

    it should be one of:

        layout.getGroupField("REC", "GROUP1", "FIELDX (1)");
    or
       layout.getGroupField("REC", "GROUP1 (1)", "FIELDX");
    

    but could well be

    layout.getGroupField("REC", "GROUP1 (1)", "FIELDX (1)");
    

    I will look at it and update to

    layout.getGroupField("REC", "GROUP1", "FIELDX (1)");
    

    Also with getGroupField you do not need to specify every Group level. Only specify the minimum to fully qualify the name. It tries to follow the "Cobol" convention.

    Reasoning:

    In Cobol adding in a Group level does not cause a problem, so people do it without thinking about it e.g.

            05 Birth-Data                   pic 9(8).
    

    becomes

            05 Birth-Data-X.
                07 Birth-Data                   pic 9(8).
    
     

    Last edit: Bruce Martin 2015-08-14

Log in to post a comment.