Search code examples
coboljrecord

JRecord - Handling duplicate columns in cobol copybook


I am using CopybookInputFormat on git https://github.com/tmalaska/CopybookInputFormat/ to generate hive table definition from COBOL copybook. My copybook has many Fillers (duplicate columns) but it looks like JRecord is not handling duplicate column name correctly. For below copybook, when I iterate columns, JRecord only prints second Filler and ignores first filler.

  05 Birth-day              PIC X(002)
  05 Filler                 PIC X(008)
  05 Birth-Month            PIC X(002)
  05 Filler                 PIC X(008)
  05 Birth-year             PIC X(004)

Does anyone have any solution for this? I know JRecord 0.80.6 onward is handling duplicate columns, but method getUniqueField("FIRST-NAME", "PRESIDENT") needs a group name.. but what if group has duplicate columns?


Solution

  • You should not need to import a Filler. In Cobol, a Filler can not be directly accessed. In Cobol a Filler say's Ignore this Field (or access it by another method).

    A Cobol-Copybook is like a mask over a block of memory; A filler is used to skip some memory.

      Data         !##........##........##   (# - accessible bytes; . - inaccessible bytes)
                    ^         ^         ^                               
                    !         !         !
    Birth-day    ---+         !         ! 
    Filler                    !         ! 
    Birth-Month  -------------+         !  
    Filler                              !
    Birth-year   -----------------------+   
    

    A filler can be used to:

    • Mask fields that are no longer used.
    • Used mask data in a redefines
    • Create a simplified version of a copybook when you do not need all the fields
    • Initializing an output field i.e
         05 report-Birth-date
            10 dd          pic 99.
            10 filler      pic '/'.
            10 mm          pic 99.  
            10 filler      pic '/'.
            10 yyyy        pic 9999.
    
    • setting up Table data
         05 codes.
            10 code occurs 5  pic 99.
         05 filler redefines codes pic x(10)
            value '0204050612'.
    

    I would ask the Cobol specialists where you work what is going on ???. Possible answers could be:

    • The filler data may not be needed.
    • You should be using a different more complicated Copybook.
    • The copybook should be updated with the Fillers given real names.