Data compression enables you to compress the data in a sequential or indexed file. There are two compression mechanisms provided with this COBOL system, run-length encoding (type 1), and extended run-length encoding (type 3).
When a file is defined with run-length encoding, any string of repeating characters is stored as a single character with a repetition count.
You enable data compression using the DATACOMPRESS Compiler directive.
Specifying data compression for a fixed structure sequential file changes it into a variable structure sequential file.
The compression used by a file is determined by the last processed DATACOMPRESS directive when the SELECT statement for the file is processed. Consequently, the compression type can be set for an individual file by using a line of the form:
immediately before its SELECT statement. You must not forget to turn it off with a $SET NODATACOMPRESS before any other files are processed.
For details on the DATACOMPRESS Compiler directive, see the topic DATACOMPRESS.
We recommend that you do not use the REWRITE statement on compressed sequential files. This is because a REWRITE operation will only succeed if the length of the compressed new record is the same as the length of the compressed old record.