HELP: Read IBM TRSMAIN/AMATERSE compressed data TYPE: OBJECT SYNTAX: TRS(MEMBER='str',BUFSIZ=num,SKPORG)
The TERSE converter can be used to compress or decompress data streams produced by the IBM TRSMAIN / AMATERSE utility on z/OS.
TERSE is a record-oriented compression format historically used on mainframes for transporting datasets off-platform (PTFs, dumps, customer-to-vendor data shipping). The decompressor accepts all four variants that IBM has shipped; the compressor produces the two algorithms that the IBM decoder accepts.
The result of a compression is a binary block. The result of a decompression can be text, XML, a base encoding or binary data. Please use delimiters, length fields or fixed length data if records must be exchanged.
Text-mode EBCDIC-to-ASCII translation is NOT performed inside this converter. Use the CNVCHR component (character conversion) after decompression and before compression if character-set conversion is required.
TERSE has two independent header layouts and two compression modes:
Header: Native (4 bytes, magic 01/07 89 69 A5) -- PACK only
Compat (12 bytes, magic 02 xx = PACK, 05 xx = SPACK)
Mode: PACK (NonSpack, faster, lower ratio)
SPACK (slower, higher compression ratio)
The decoder handles all four combinations automatically (from the header bytes). For the compressor, the MODE and HDRTYP parameters select the output variant. The default is MODE=PACK HDRTYP=COMPAT, which is the variant AMATERSE emits in most configurations.
When the Compat header is used, the compressor stores the original DCB metadata (record format and record length) so the decompressor can reconstruct the correct dataset attributes. The RECFMT and RECLEN parameters control this:
RECFMT=AUTO - take the record format from the upstream FIO context
(default; typically yields F for flat byte streams
and V for variable-length record sources)
RECFMT=F - force fixed-length record format
RECFMT=V - force variable-length record format
RECLEN=0 - AUTO (take from upstream FIO context, default)
RECLEN=n - store literal record length in the Compat header
For RECFM=V input the compressor expects MVS-style RDW-prefixed records (4-byte RDW followed by data); it strips the RDW and inserts a RECORDMARK between records so the decompressor can restore the records exactly.
AMATERSE on z/OS also stores three optional DCB-related fields in the Compat header: flags bit 0x04 (MVS origin), block size, and a ratio byte. These are informational; the non-MVS default leaves all three at zero. Activate by setting ISHOST and optionally BLKSIZ / RATIO:
ISHOST - set the Compat flags-byte bit 0x04 (MVS-origin marker)
BLKSIZ=n - z/OS block size stored in the Compat header [0 = AUTO]
When 0 (the default), the block size is computed as the
largest multiple of the physical record length that fits
in the 16-bit Compat field (max 65535). Set explicitly
only when interoperating with systems that require a
specific block size; requires ISHOST.
RATIO=n - z/OS ratio byte (0..255); requires ISHOST
The TERSE compressor always writes exactly one stream per invocation. MEMBER=:1 is accepted for symmetry with other converters but selects the only stream present; any other member index returns an error.
The TERSE decompressor handles concatenated TERSE files: if the input contains multiple consecutive TERSE streams (as produced by appending AMATERSE or FL5 output files), all streams are decoded in sequence and the decoded payloads are concatenated in the output. Arbitrary uniform padding bytes between streams (for example 0x00 from FB block-fill, 0x40 from EBCDIC space, 0x20 from ASCII space) are skipped automatically. Leading padding before the first header is not tolerated (auto-detection requires the TERSE magic bytes at offset 0).
TERSE is the IBM-assigned PKZIP compression method 18 (IBM-TERSE). When read from a PKZIP archive that stores a member with method 18, this converter is invoked automatically on the member payload. When writing a PKZIP archive with CNV.ZIP(ALGO=TERSE), the resulting member is stored as method 18 and contains a naked TERSE stream. Note that desktop unzip tools do not typically support method 18 -- extraction requires either FL5 or a z/OS tool chain.
Typical SPACK compression on English text reaches 0.002-0.05 (output is 0.2-5% of input size). PACK is faster but less thorough; expect ratios around 0.05-0.6. Random or already-compressed data stays near 1.0 (no compression).
Decompress a TERSE file received from z/OS. DECODE=DECOMP activates auto-detect; the TERSE magic bytes are recognized automatically.
flcl conv "read.binary(file='ivpdb1.trs',decode=decomp)" \
"write.binary(file='ivpdb1.bin')"
Compress a local binary file with default PACK+Compat. Use the COMPRESS overlay under write.binary and select the TERSE sub-object via dotted overlay syntax:
flcl conv "read.binary(file='data.bin')" \
"write.binary(file='data.trs',compress.terse())"
Compress with SPACK (higher compression), mark as z/OS origin:
flcl conv "read.binary(file='data.bin')" \
"write.binary(file='data.trs',compress.terse(mode=spack,ishost))"
Package a TERSE-compressed member inside a PKZIP archive (method 18). Use ARCHIVE.ZIP with ALGO=TERSE:
flcl conv "read.binary(file='data.bin')" \
"write.binary(file='data.zip',archive.zip(algo=terse))"
Note: the COMPRESS.TERSE() overlay used under WRITE.BINARY exposes the core format switches (MODE, HDRTYP, ISHOST, RATIO, SKIP). The block size (BLKSIZ) and record format/length overrides (RECFMT, RECLEN) are available only in the full CNV.TRS() entry (reachable via the generic CNV converter chain in the INPUT/SAVE path). In the COMPRESS.TERSE() context, RECFMT and RECLEN are always derived from the upstream FIO record attributes, and the block size is computed automatically.
STRING: MEMBER='str' - Index of the member in the TERSE/AMATERSE file to readNUMBER: BUFSIZ=num - Initial buffer size for preallocation [65536]SWITCH: SKPORG - Skip decompression if original was copied [FALSE]