


The compiler needs to give a name to each XFD file (data dictionary) that is built. It attempts to build the name from your COBOL code, although there are some instances where the name in the code is nonspecific, and you must provide a name.
Each XFD name is built from a starting name that is derived (if possible) from the SELECT statement in your COBOL code. The following paragraphs explain how that occurs.
ASSIGN name is a variable
If the SELECT for the file has a variable ASSIGN name (ASSIGN TO filename), then you must specify a starting name for the XFD file via a FILE directive in your code. This process is described in Chapter 4.
ASSIGN name is a constant
If the SELECT for the file has a constant ASSIGN name (such as ASSIGN TO "COMPFILE"), then that name is used as the starting name for the XFD name.
ASSIGN name is generic
If the ASSIGN phrase refers to a generic device (such as ASSIGN TO "DISK"), then the compiler uses the SELECT name as the starting name.
Forming the final XFD name
From the starting name, the final name is formed as follows:
The compiler removes any extensions from the starting name.
It constructs a "universal" base name by stripping out directory information
that fits any of the formats used by the operating systems that run the
ACUCOBOL-GT compiler.
It reduces the base name to eight characters and converts it to lower case.
It appends the letters ".xfd" to the base name.
Examples of XFD names
| COBOL code:
| File name:
|
| ASSIGN TO "usr/ar/customer.dat"
| customer.xfd
|
| SELECT TESTFILE, ASSIGN TO DISK
| testfile.xfd
|
| ASSIGN TO "-D SYS$LIB:HELP"
| help.xfd
|
| ASSIGN TO FILENAME
| (you specify) |
At runtime, it is possible to use a single XFD for files that have different names. For example, suppose a site has customer files that have identical structures but different names (CUST0001, CUST0002, CUST0003, etc.). It's not necessary to have a separate XFD for each file, so long as their record definitions are the same.
The individual files can all be mapped to the same XFD via a runtime configuration variable called XFD-MAP. The following paragraphs describe how it works.
Suppose your COBOL application has a SELECT with a variable ASSIGN name, such as customer-file. This variable assumes different values (such as CUST0001 and CUST0002) during program execution.
Before compiling the application, you would use the FILE directive (see Chapter 4) to provide a base name for the XFD. Suppose you provide "CUST" as the base. The compiler would then generate an XFD named "cust.xfd". (The compiler always converts XFD names to lower case.)
To ensure that all customer files, each having a unique name, will use this same XFD, you make this entry in your runtime configuration file:
XFD-MAP CUST* = CUST
The asterisk (*) in the example is a wildcard that matches any number of characters. Note that the extension ".xfd" should not be included in the map. This statement would cause the XFD "cust.xfd" to be used for all files whose names begin with "CUST".
The XFD-MAP variable has this syntax:
XFD-MAP [pattern = base-xfd-name] ...
where pattern consists of any valid filename characters and may include "*" or "?". These two characters have special meanings in the pattern:
* matches any number of characters
? matches a single occurrence of any character
For example:
CUST???? matches CUST0001 and CUSTOMER
does not match CUST001 or CUST00001
CUST* matches all of the above
CUST*1 matches CUST001 and CUST0001 and
CUST00001 does not match CUSTOMER
* OMER matches CUSTOMER
does not match CUST001 or CUST0001
The XFD-MAP variable is read during the open file stage of any Acu4GL products linked into the runtime.
XFD values can be replaced or be added to the end of existing XFD map values by setting the XFD-MAP-RESET configuration variable. This configuration variable determines whether setting the XFD-MAP adds to or replaces the existing value. When this variable is set to "0" (off, false, no), setting the XFD-MAP adds new value patterns to the end of the existing value. When it is set to "1" (on, true, yes), setting the XFD-MAP replaces the existing value with a new value. The default value is "1" (on, true, yes).
This variable may be useful if you need to include multiple XFD-MAP lines in a configuration file, and want to avoid setting and resetting the variable. When multiple lines exist, all patterns are used in the order they are listed.