contents.gifindex.gifprev1.gifnext1.gif

7.2.2 Defaults Used in XFD Files

There are several elements of COBOL that require special handling when data dictionaries are built. These include multiple record definitions, REDEFINES, FILLER, and OCCURS. This section describes how ACUCOBOL-GT handles each of these situations.

As described earlier, in many instances you can override the default behavior described below by placing directives in the FDs of your COBOL code. Directives are described in Section 7.3 Using Directives. For example, the WHEN directive allows you to use multiple definitions for a single set of data by specifying when each definition should be used.

Like most data sources, Vision does not support the notion of multiple definitions for the same column. As the following paragraphs explain, whenever a COBOL program gives more than one definition for the same data, the compiler makes a choice about which definition to use in the dictionary. Then it disregards the rest.

KEY IS phrase

Fields named in KEY IS phrases of SELECT statements are included as column names in the "virtual" database. Other fields that occupy the same areas as the key fields (by either explicit or implicit redefinition) are not included by name, but are mapped to the key field column names by the data dictionary.

Remember, if the field named in the KEY IS phrase is a group item, it will not be included in the XFD unless a USE GROUP directive is used (see "Understanding how the data dictionary is formed" above).

REDEFINES clause

Fields contained in a redefining item occupy the same positions as the fields being redefined. The compiler needs to select only one of the field definitions to use. The default rule that it follows is to use the fields in the item being redefined as column names; fields that appear subordinate to a REDEFINES clause are mapped to column names in the "virtual" database using the data dictionary.

Multiple record definitions

This same rule extends to multiple record definitions. In COBOL, multiple record definitions are essentially redefinitions of the entire record area. This leads to the same complication that is encountered with REDEFINES: multiple definitions for the same data. So the compiler needs to select one definition to use.

Because the multiple record types can be different sizes, the compiler needs to use the largest one, so that it can cover all of the fields adequately. Thus, the compiler's rule is to use the fields in the largest record defined for the file. If more than one record is of the "largest" size, the compiler uses the first one.

Group items

Note that group items are, by default, never included in a data dictionary for the same reason that REDEFINES are excluded: they result in multiple names for the same data items. You can, however, choose to combine grouped fields into one data item by specifying the USE GROUP directive, described in Section 7.3.8 Use Group Directive.

FILLER data items

In a COBOL FD, FILLER data items are essentially place holders. FILLER items are not uniquely named and thus cannot be uniquely referenced. For this reason, they are not placed into the Acucorp data dictionary. The dictionary maintains the correct mapping of the other fields, and no COBOL record positional information is lost.

If your Windows application refers to a FILLER data item, you may need to include it. In such a case, you could include it under a USE GROUP directive or give it a name of its own with the NAME directive, described in Section 7.3.6 Name Directive.

OCCURS clauses

An OCCURS clause always requires special handling, because the ACUCOBOL-GT compiler must assign a unique name to each database column. The compiler accomplishes this by appending sequential index numbers to the item named in the OCCURS.

For example, if the following were part of a file's description:

03 employee-table occurs 20
 times.
 05 employee-number pic 9(3)

then these column names would be created in the "virtual" database table:

employee_number_1
employee_number_2
.
.
.
employee_number_10
employee_number_11
.
.
.
employee_number_20

Note that the hyphens in the COBOL code are translated to underscores in database field names, and the index number is preceded by an extra underscore.