Directives are comments that can be placed into an FD in your COBOL source code. You can add directives to your COBOL source to override default mapping behaviors or map a field to a different name. Directives apply to the next field and up to 4 directives per field can be specified.
For compatibility with existing ACUCOBOL-GT source code, xddgen accepts the following $xfd and *>>XFD directives:
DATE, HIDDEN, NAME, USE GROUP, WHEN, ALPHA, BINARY, COMMENT
Syntax
*>>directive_name parameters
Note: For fixed syntax, the directive must start at column 8.
Supported Directives
XDD ALPHA
This option forces the resulting field to be ALPHANUMERIC. An index can then be created via SQL that provides expected range sorting on the value.
Syntax
*>>XDD ALPHA
XDD HIDDEN
Use the HIDDEN directive to hide the subsequent field in the SQL structure.
Syntax
*>>XDD HIDDEN
XDD NAME
Use the NAME directive to assign a database field name to the subsequent field.
Syntax
*>>XDD NAME = field
XDD USE GROUP
Use the USE GROUP directive to enter a group item into the database as a single field, instead of using the elements contained in the group. It implies that the resulting field is alphanumeric.
Syntax
*>>XDD USE GROUP
XDD DATE
Use the DATE directive to expose the subsequent field in SQL as a time/date/timestamp field in SQL. The date_format is mandatory and represents the description of the desired date format for the XDD file.
Syntax
*>>XDD DATE = date_format
where
M - Month (01–12)
Y - Year (two or four digits)
D - Day of month (01–31)
J - Julian day (00000000–99999999)
E - Day of year (001–366)
H - Hour (00–23)
N - Minute
S - Second
XDD WHEN
Use the WHEN directive when you want to include multiple record definitions or REDEFINES in the XDD. The WHEN directive is used to force certain columns of data to be available that wouldn't be available otherwise. Use the WHEN directive if you want a user to be able to access all the data in the COBOL file in a way that is understandable.
WHEN declares that the field (or subordinate fields, if it is a group item) immediately following the directive must appear as a column (or columns) in the indexed file database table when the condition is satisfied.
Syntax
*>>XDD WHEN field operator value
or
*>>XDD WHEN field operator value TABLENAME = tablename
where
operator - Specifies the operator to use for comparison between the field value and the literal value.
Supported operators:
= equal
!= not equal
> greater than
< less than
>= greater or equal than
<= less or equal than
The WHEN directive supports complex expressions containing multiple AND and OR operations and parentheses to group sub-expressions for proper order of evaluation.
The maximum length of the expression is 1024 characters (no need to split the line). For example:
*>>XDD WHEN (fld1 = "abac" or fld1 = "default") and (fld2 < 15 or fld2 > 123) and fld4 != "12"
If you have need for an existing $XFD WHEN directive in place and would like a different WHEN directive in effect (for example, complex directives were not supported with old ACUCOBOL-GT versions) a *>>WHEN directive immediately following a $XFD WHEN directive overrides it. This is a useful method to have an original $XFD WHEN in place for other file systems and *>>WHEN directives for c-tree specific usage.
Multiple schemas can be defined with the same definition but different records and mapping to different SQL tables by specifying multiple WHEN directives having different tablename settings on the same field.
For example, your application may use a single table containing customers and suppliers with a TYPE field indicating if an entry is for a customer or for a supplier. It may be desirable to map this table into two SQL tables; one for suppliers and one for customers. In such a case it is possible to have two WHEN directives on the same level 01 field (in this example) with the proper condition and two different table names.
Nested WHEN directives are not explicitly supported.
XDD WHENFULL - redefined key fields
Use the WHENFULL directive in the FD or COBOL source when you want to include multiple record definitions or REDEFINES that also redefine the indexed fields. This directive is very similar to the WHEN directive.
The WHENFULL directive can only be used before an 01 level definition and the 01 level entry must contain the whole record definition (including indexed fields). WHENFULL is applicable only for 01 level definitions that redefine the entire record.
It is possible to nest WHEN directives within a WHENFULL directive.
XDD FILLER
This directive forces the following field to be considered to be a FILLER.
Syntax
*>>XDD FILLER
See also: