The COBOL standards

1 The Four Status Codes
1.1 ISCOBOL_STATS
2 Duplicate Status on read/write
3 The Data File Extension
3.1 ISCOBOL_NO_NEW_EXT
3.2 ISCOBOL_NO_DAT_EXT
3.3 ISCOBOL_ANY_EXT

1 The Four Status Codes

The ISCOBOL define in head/isconfig.h includes an option to provide the four COBOL status variables, isstat1 through isstat4 in the standard interface.

1.1 ISCOBOL_STATS

Include support for COBOL status variables.

The base API no longer provides the four isstat fields in the ISAM file descriptor, and instead overloads the entire set of four status values, plus the normal error return, onto iserrno in the descriptor, or the global errno variable, if no descriptor is assocated.

By this means the base API is able to return status codes from errors in the open and build calls, as well as from operations on open ISAM files, and at the same time is able to benefit from the threadsafe nature of more recent errno implementations.

On the other hand, when using the base API, it now becomes essential to use the official isErrno call to read the current error code, and/or the new isCobolErr call to load the status codes.

If this is too cumbersome, you can also compile a copy of the base library without ISCOBOL_STATS to link with your existing base calls, and build a separate base library, with stats and the wrapper layer included, to link with COBOL.

In the wrapper API, the overloaded error code is translated automatically into the global isstat1 through isstat4 variables, and iserrno is reset to the standard values.

2 Duplicate Status on read/write

When a record is written that adds a duplicate to any index, and when a record is read that is followed by a duplicate key in the current index, the status code 0202 is set, in the wrapper API.

These are the only circumstances under which DISAM will return a status code when there is no error condition.

This allows COBOL programs to detect when a duplicate has been created, and when the next read will produce a duplicate.

This does not work when reading in natural record order, nor (currently) for pure indexes.

When duplicates are created during writes, this flag is set directly, as part of the normal insert procedure, and no cycles are wasted.

When reading, as long as the current index has DCOMPRESS turned on, the duplicate status is stored in the top bit of the record number in the index node structure, and this provides an immediate and efficient mechanism that should be reliable in all cases.

However, if the index in question is not compressed, the flag bit is not maintained, and the only remaining option is to search ahead for the next key in the index. While this may seem trivial, it can almost triple the time DISAM takes to read each record, although it should also be reliable.

3 The Data File Extension

The ISCOBOL define in head/isconfig.h provides three additional options which may be helpful here.

3.1 ISCOBOL_NO_NEW_EXT

New data files will be created without the .dat extension.

3.2 ISCOBOL_NO_DAT_EXT

Data files are expected to be without a .dat extension.

3.3 ISCOBOL_ANY_EXT

Data files may have a .dat or no extension on open.