PreviousRun-time Triggers, Configuration and Switches

Chapter 8: File Handling

This chapter describes changes to the Micro Focus file handling systems that might affect the migration of applications to Server Express.

8.1 Error Messages

File handling errors that returned messages of the form 9/035, which you might have received on previous versions of COBOL for UNIX, are now returned as 9/037 instead.

8.2 Multiple-reel Files

You can specify that sequential files are multiple-reel files, which enables you to span files across media; for example, you could specify that a file is to be held on more than one removable disk.

If you specify that a sequential file is multiple-reel, you will be requested to load the appropriate reel; at the prompt, you must specify the appropriate device for that volume. However, previous versions of COBOL for UNIX incorrectly enabled you to enter a new name for the volume. If you have any batch programs, scripts, job-control, and so on, that make use of this erroneous operation of the prompt, you must modify them.

For details of using multiple-reel files, see the section Multiple-reel Files in the chapter Miscellaneous Topics in your File Handling book.

8.3 External File Handler

Server Express supports the External File Handler. For details of migration, refer to the section External File Handler in the chapter If You're Using... .

8.4 DATAFILE and INDEXFILE Configuration Options

In earlier products, by using a name of the form &datafilename&indexfilename, you could place the index portion and data portion of an indexed file on different directories. For example, with a name such as &/disk1/data.dat&/disk2/data.idx, the data part of the file would be placed in /disk1/data.dat and the index part in /disk2/data.idx.

In the current product, this functionality is provided by means of the configuration options DATAFILE and INDEXFILE. You can specify these configuration options in the file handler configuration file extfh.cfg. For example, if the assignment name is data.dat, the above disposition of files can be achieved by placing the following in extfh.cfg:

[data.dat]
datafile=/disk1/data.dat
indexfile=/disk2/data.idx

8.5 Filenames with Leading Hyphens

On earlier products, if a file name set up in the COBOL program began with the '-' (hyphen) character, that character was dropped from the name used for the actual disk file. For example, if the file name set up by the COBOL program was -file.dat, the name of the file on disk would be file.dat.

This product retains the hyphen character in the filename of the file on disk. Therefore, in the example given above, the name of the file on disk would be -file.dat in this product.

8.6 Filename Mapping

Server Express provides two methods of filename mapping. You do not have to restrict yourself to using one or the other. The two methods are compatible.

8.6.1 Method 1

With earlier products, and for some file types only, you could map filenames onto different names. To do this, you had to:

  1. Set up an environment variable with the same name as the original file name.

  2. Give the environment variable a value equal to the target file name.

In Server Express, for this to still work you must also do one of the following:

8.6.2 Method 2

In addition, Server Express provides the following method:

  1. Set up an environment variable with the same name as the original file name but prefixed by either dd_ or DD_. Therefore for a file named file, you would set up the environment variable either as dd_file or DD_file.

  2. Give the environment variable a value equal to the target file name.

Note: Server Express begins by searching for the dd_ environment name. If this search is unsuccessful and you have employed Method 1, either by using ASSIGN(EXTERNAL) or by prefixing the name with $, Server Express looks for an environment variable name with the same name as the filename.


8.6.3 Example 1

If the COBOL program has ASSIGN TO EXTERNAL DATFILE1:

  1. Server Express searches for an environment variable named dd_DATFILE1.

  2. If not found, Server Express searches for an environment variable named DD_DATFILE1.

  3. If not found, Server Express searches for an environment variable named DATFILE1.

If any of these environment variables are found, Server Express uses the value held in the environment variable as the actual file name. Otherwise the name DATFILE1 is used.

8.6.4 Example 2

If the COBOL program has:

ASSIGN TO filename

and the data item filename contains the value DATFILE2:

  1. Server Express searches for an environment variable named dd_DATFILE2. If it is found, Server Express uses the value held in the environment variable as the actual file name.

  2. If dd_DATFILE2 is not found, Server Express searches for an environment variable named DD_DATFILE2. If it is not found, Server Express uses the value held in the environment variable as the actual file name.

  3. If neither dd_DATFILE2 nor DD_DATFILE2 are found, Server Express uses the name DATFILE2.

8.7 File Handler and isam_open_key_check

The file handler does not recognize the isam_open_key_check run-time tunable. To get round this, set the configuration option KEYCHECK to either ON or OFF, either globally or on a per-file basis. For more information, see the section Configuration Options in the File Handler Configuration chapter of the File Handling book.

Even when you set KEYCHECK to OFF, the file handler still checks that the keys presented to it are a subset of the actual keys defined on the file. However, with KEYCHECK set to OFF, you do not have to define every key. For example, if you set KEYCHECK to OFF and the file has a prime key and 9 alternate keys, you can allow the file to be opened by specifying, say, only 5 of these alternate keys, provided that each of the keys specified is really a key for the file.

8.8 File Status and filestat.c

On earlier products, you could change the file filestat.c to provide alternative file status values. By default, the alternative file status values that filestat.c was able to provide were for RM/COBOL, although you could also define other file status values if you required.

On Server Express, the filestat.c file is no longer provided. If you want to change the file status values to emulate those returned by another COBOL product, you should set the CONVERTSTATUS option in the file handler configuration file. For information on configuring the file handler, see the File Handler Configuration chapter of your File Handling book.

8.9 Sharing Files Opened for Input

On earlier products, if a program opened a data file for input, without using the sharing syntax in the SELECT clause (LOCK MODE IS AUTOMATIC or MANUAL), the file behaved as if sharing had been specified; that is, programs that did have sharing specified in their SELECT clause could also open the file for input-output operations and modify the file. In Server Express, the default behavior of the file handler has been changed so that this is no longer possible. By default, therefore, if a program opens a file for input (and that program has not specified that the file can be shared), other programs can open the file for input, but not for input-output.

If you want your applications to use the locking behavior that was available in the earlier products, set the file handler configuration parameter OPENINPUTSHARED to ON. However, this slows down access to the input file. You can minimize this performance degradation using the file handler configuration options:

IGNORELOCK=ON
READSEMA=OFF

For details on the file handler configuration options see the File Handler Configuration chapter of your File Handling book.

8.10 Sequence-checking Indexed File Keys

On earlier products, you could set the K run-time switch to enable sequence-checking of keys in indexed files. The K switch has been removed from this version of the product. Compatibility with this switch is provided by the configuration option NOSEQCHECK. We do, however, strongly suggest that you control the order in which records are written to indexed files within the program itself, by using the ACCESS SEQUENTIAL or ACCESS DYNAMIC syntax, and avoid using the NOSEQCHECK configuration option.

8.11 FCD3 Format

In Server Express 2.0, the format of the File Control Description (FCD) has been changed from FCD2 to FCD3. Only FCD3 format can be used in 64-bit compilations. Both FCD2 and FCD3 format can be used in 32-bit compilations. To aid conversion of programs which use the FCD directly, you can use:

For more information, see the section File and FCD Handling in the chapter Creating 64-bit Programs in Programmer's Guide to Writing Programs.


Copyright © 2000 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousRun-time Triggers, Configuration and Switches