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 topic describes how the compiler handles each of these situations.
Note that in many instances you can override the default behavior described below by placing special comment lines in the FDs of your COBOL code. These comments are called directives, and are described in the Using Directives section. 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.
Databases generally do 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. 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 become a column in the database table unless a USE GROUP directive is used (see Understanding how the database table is formed). Instead, the subordinate fields of the group item will be used.
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 by 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.
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 ACUCOBOL-GT data dictionary. The dictionary maintains the correct mapping of the other fields, and no COBOL record positional information is lost.
Sometimes you need to include a FILLER data item, such as when it occurs as part of a key. 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.
OCCURS clauses
An OCCURS clause always requires special handling, because the Acu4GL runtime system must assign a unique name to each database column. The runtime 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 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.
XFD Location
As long as the object library is loaded, XFD files can be embeded into COBOL objects through cblutil and the runtime will find them. This is particularly effective when you are using the ACUCOBOL-GT Plug-in and Acu4GL. It allows you to send all of the COBOL objects, as well as XFD files, in one package.
Please note that if an XFD file is located in an object library, and is also located on the disk (in the directory pointed to by the XFD-Directory configuration variable), the XFD file in the object library is loaded first, unless the XFD-Directory configuation variable uses remote name notation.