COMPRESS

See also:
EXPAND in this section.


                       ____________________________________________________
                      |             |                    |                 |
                      |             |          n AT p1   |       n AT p2   |
                      |   COMPRESS  |   (FROM)           |   TO            |
                      |             |   ( FR )    p1     |          p2     |
                      |_____________|____________________|_________________|

Storing data is extremely inefficient when the data consists of many embedded blanks and other duplicated characters. To avoid this inefficiency, the COMPRESS/EXPAND facility allows compression before writing, and expansion back to the full record size after reading a compressed record.

COMPRESS and EXPAND operate on storage only, and are not concerned with any particular file.

If the source length is not provided, the default length used for the COMPRESS statement is LRECL.

After compression or expansion, the LRECL value is modified to reflect the size of the compressed or expanded data.

It is possible that the compressed data is longer than the source.





Restrictions

  1. Source and destination may not overlap.
  2. Destination length, if provided, does not cause the operation to fail if its confines are exceeded. However, a syntax error will occur if the destination field is not within the work area.
  3. For AS/400, UNIX and PC, the optional FROM parameter has been made mandatory.
    Thus:
    COMPRESS  1           TO 1001                * Gives a syntax error.
    COMPRESS  FR 1        TO 1001                * Acceptable. (Length=LRECL.)
    COMPRESS  456 AT 1    TO 1001                * Acceptable.
    COMPRESS  LRECL AT 1  TO 1001                * Acceptable.
    





Example

For back-up purposes, the following statements would be suitable:

READ BIGFILE    NORDW    W=2222              * Read normal file.
COMPRESS FR 1         TO=1001                * Compress LRECL bytes.
WR TAPEFIL  RECFM=VB  FR=1001  B=32000 L=512 * Write Back-up.

The NORDW parameter has been included on the input file because we do not wish to include any RDW in the compression algorithm. If input is not RECFM=V, then the NORDW parameter is simply accepted with no error message because RECFM=F and RECFM=U records have no RDW anyway.
SELCOPY will of course generate an appropriate RDW for the output file which is explicitly coded as RECFM=V.

COMPUTE(Bridgend)Ltd UK Tel:+44(1656) 65 2222 Fx:2227
2003/07/31 Op Wd - COMPRESS SELCOPY Rel 2.0x