Quickly retrieve the number of records of a file




FOR INDexed files,

You can get the number of records using the FCD-RELATIVE-KEY of  the structure File Control Description (FCD).

You can have the FCD on-line in your prog:

or assigning the FCD in your program using the FCDREG compiler directive

or using the EXTFH function x"0006" == File Information


For Line Sequential files, you can use the UNIX command wc-l , using a PIPE to retrieve the output of this command



The content of the  File Control Description (FCD) is documented in Micro Focus products


The program RCCOUNT.cbl uses the FCDREG compiler directive and assigns the FCD for a file .


The program EXTFHINFO uses

-- the EXTFH function FileInformation  function x"0006"

to retrieve various informations for a specific file ( INDexed and SEQUENTIAL Variable Length )...

--the UNIX command wc -l to retrieve the number of records of a Line Sequential file





File Information

Returns general file information for all file organizations with headers and, for indexed files, information on the file keys in the form of the key definition block.

Opcode Operation File Types

06 Return file information I vS vR

Input Fields

fcd-organization File organization (can be x"FF")

fcd-name-length Length of filename

fcd-filename-address Pointer to the filename area

fcd-key-def-address Pointer to the key definition block (I)

Output Fields

Key definition block (I)  

fcd-file-status File status

fcd-organization File organization

fcd-file-format File format

fcd-max-rec-length Maximum record length

fcd-recording-mode Recording mode

fcd-min-rec-length Minimum record length

fcd-reladdr-offset or fcd-reladdr-big File size

fcd-data-compress Data compression routine

It is your responsibility to ensure that you have enough space allocated for the key definition block to hold all the information returned. Failure to allocate enough space causes corruption of some data areas.

For variable-length sequential files and variable-length relative files, no key definition information exists.

If you can set the organization byte of the FCD to x"FF" before using this operation code, an attempt is made to determine the file type and return with the relevant information set. This mode of operation is not recommended if you use any fixed-length sequential files as it might be impossible to determine the difference between the first record of a fixed-length sequential file and the header of a variable-length sequential file. If the file type cannot be determined, the error code 9/161 is returned.

Pivotal ID: 23465 Author: Yvon Abgrall Created on: 2007-01-08 Product: Server Express Category:


Old KB# 2005
Comment List