Field Causes Duplicate Database Data

Hello, I'm getting a file error:

Field ITEM-DEL-LINK-UPC causes duplicate database data

This error is due to my using the -Fx option when compiling the program that uses this file, and is due to a key existing inside of another key. My question is, is there an easy way to resolve this issue? We have clients running this software that have data already in this file, and we'd like to avoid a file conversion if at all possible. The FD and Select are as follows:

       SELECT OPTIONAL ITEM-DEL-FILE
           ASSIGN       TO RANDOM "./inv/itemdelete"
           WITH COMPRESSION
           COMPRESSION CONTROL VALUE  70
           ORGANIZATION IS INDEXED
           ACCESS MODE  IS DYNAMIC
           FILE STATUS  IS ITEM-DEL-STAT
           RECORD KEY   IS ITEM-DEL-KEY
           ALTERNATE RECORD KEY IS ITEM-DEL-UPC-KEY = ITEM-DEL-UPC,
           ITEM-DEL-TYPE
           WITH DUPLICATES
           ALTERNATE RECORD KEY IS ITEM-DEL-LINK-KEY =
           ITEM-DEL-LINK-UPC, ITEM-DEL-TYPE
           WITH DUPLICATES .

       FD  ITEM-DEL-FILE
           RECORD CONTAINS 2252 CHARACTERS
           LABEL RECORD IS STANDARD.
       01 ITEM-DEL-RECORD.
           03 ITEM-DEL-KEY.
               05 ITEM-DEL-DATE    PIC  9(8)
                          USAGE IS COMP-6.
               05 ITEM-DEL-TYPE    PIC  X.
               05 ITEM-DEL-STATUS  PIC  X.
               05 ITEM-DEL-UPC     PIC  9(16)
                          USAGE IS COMP-6.
               05 ITEM-DEL-REST    PIC  X(14).
               05 ITEM-DEL-REST2 REDEFINES ITEM-DEL-REST.
                   07 ITEM-DEL-LINK-UPC            PIC  9(16)
                              USAGE IS COMP-6.
                   07 FILLER           PIC  X(6).
               05 ITEM-DEL-REST3 REDEFINES ITEM-DEL-REST.
                   07 ITEM-DEL-PROMO-NO            PIC  X(8).
                   07 ITEM-DEL-PROMO-TYPE          PIC  X.
                   07 FILLER           PIC  X(5).
               05 ITEM-DEL-REST4 REDEFINES ITEM-DEL-REST.
                   07 ITEM-DEL-ORDNO-RANK          PIC  X.
                   07 FILLER           PIC  X(13).
               05 ITEM-DEL-REST5 REDEFINES ITEM-DEL-REST.
                   07 ITEM-DEL-AGE-DATE            PIC  9(8)
                              USAGE IS COMP-6.
                   07 ITEM-DEL-AGE-TIME            PIC  9(6)
                              USAGE IS COMP-6.
                   07 ITEM-DEL-AGE-TYPE            PIC  99
                              USAGE IS COMP-6.
                   07 ITEM-DEL-AGE-SEQ PIC  99
                              USAGE IS COMP-6.
                   07 FILLER           PIC  X(5).
           03 ITEM-DEL-PROGRAM PIC  X.
           03 ITEM-DEL-USER    PIC  X(3).
           03 ITEM-DEL-TIME    PIC  9(8)
                      USAGE IS COMP-6.
           03 ITEM-DEL-DATA    PIC  X(1536).
           03 ITEM-DEL-FILLER  PIC  X(98).

Thanks In Advance,

Dave

  • You can use the NAME directive to rename this field .. it will not change the FD but will allow the database to have a column name based on the Name directive.

               05 ITEM-DEL-REST2 REDEFINES ITEM-DEL-REST.

    $XFD NAME=ITEM-DEL-LINK2-UPC

                      07 ITEM-DEL-LINK-UPC            PIC  9(16)

  • Verified Answer

    You can safely ignore this warning message.  I assume, since you mention having data already in the file, that you have Vision data and are creating an XFD for use with AcuXDBC.  (The other common reason for creating an XFD is for use with Acu4GL).  The message you're getting is just a warning, and it's intended primarily for Acu4GL users.  It warns that you'll have more than one database column holding copies of the same COBOL data.  If an external process modified a row in the database table, without keeping the duplicated data in sync, it would cause Bad Things when accessing the data again from COBOL.

    In the case of AcuXDBC, you'll see different columns in the SQL view of your Vision data that will represent the same underlying COBOL data field.  In your case, you'll have a column named ITEM_DEL_REST, and another named ITEM_DEL_LINK_UPC, where both represent some or all of the same data (although because they're different data types, the contents may look odd in some cases).

    If you really want to get rid of the warning, you'll need to rearrange the FD.  If you're careful, you can do it without changing the layout of the existing data file.  For instance, this might work (but I haven't tested it, so proceed at your own risk!):

    1. Change ITEM-DEL-REST into a group item

    2. Add sub-items to match its original size/type, and also match the layout of ITEM-DEL-REST2 that redefines it

    i.e. change this:

                   05 ITEM-DEL-REST                    PIC  X(14).
                   05 ITEM-DEL-REST2 REDEFINES ITEM-DEL-REST.
                       07 ITEM-DEL-LINK-UPC            PIC  9(16)
                                                       USAGE IS COMP-6.
                       07 FILLER                       PIC  X(6).
    

    To this:

                   05 ITEM-DEL-REST.
                       07 ITEM-DEL-REST-1A             PIC  X(8).
                       07 ITEM-DEL-REST-1B             PIC  X(6).
                   05 ITEM-DEL-REST2 REDEFINES ITEM-DEL-REST.
                       07 ITEM-DEL-LINK-UPC            PIC  9(16)
                                                       USAGE IS COMP-6.
                       07 FILLER                       PIC  X(6).
    

    You'll end up with a columns named ITEM_DEL_LINK_UPC and ITEM_DEL_REST_1B.  You won't get ITEM_DEL_REST_1A because it's now an exact duplicate of  ITEM_DEL_LINK_UPC, which takes precedence because it's a key field.


    FYI, there is a discussion of this compiler warning message in the Acu4GL User's Guide (Chapter 9, Section 9.2.2)