How XFDs are Formed

XFDs enable the interface to create a table (or access an existing one) in the database for each indexed file. Each column in the table contains the values for one field. The column names are essentially the field names.

The table that is built is based on the largest record in the COBOL file and contains the fields from that record plus any key fields (key fields are those that are named in KEY IS phrases of SELECT verbs in the FILE CONTROL section). This ensures that data from all COBOL records fit within the table and simplifies the storage and retrieval process. If you were to examine the database columns, only the fields from the largest record, and the key fields, would appear. For additional information, see Defaults Used in XFD Files.

Note: If the field named in the KEY IS phrase is a group item, it does not become a column in the database table. Instead, each of the elementary items subordinate to the named group item become a column. You can force a group item to be a column by using the USE GROUP XFD directive.

With multiple record formats (level 01), not all COBOL fields are represented in the database by name, but all fields are storable and retrievable. The XFD maps fields from all records of a file to the corresponding locations in the master (largest) record of the file, and thus to the database table. Since Acu4GL has access to the XFD, it knows where the data from a given COBOL record fits in the database tables. This activity is invisible to the COBOL application.

For example, if your program has one file with the three records shown below, the underlined fields are included in the database table by default (this example assumes that ar-codes-key is named in a KEY IS phrase). Some fields do not appear in the table, but the XFD maps them to the master field names. Acu4GL thus eliminates redundancies for optimum performance.

01  ar-codes-record.
    03  ar-codes-key.
        05  ar-code-type      pic x. 
        05  ar-code-num       pic 999.
01  ship-code-record.
    03  filler                pic x(4).
    03  ship-weight           pic s999v9.
    03  ship-instruct         pic x(15).
01  terms-code-record.
    03  filler                pic x(4).
    03  terms-rate-1          pic s9v999.
    03  terms-days-1          pic 9(3).
    03  terms-rate-2          pic s9v999.
    03  terms-descript        pic x(15).

The following diagram shows how Acu4GL creates database columns for some of the fields in the COBOL record, while the XFD maps other fields to those columns; this means that all of the fields are accessible to the COBOL program.


Making Field Accessible to COBOL Programs

See Defaults Used in XFD Files for a description of rules that Acu4GL follows as it builds the database table and an explanation of how you can override those rules when necessary.