#### ZIP

#### Synopsis

    HELP:   Write data to ZIP archive
    TYPE:   OBJECT
    SYNTAX: ZIP(MEMBER='str',MBRATR/MEMATR(),ALGO=COPY/DEFLATE/BZIP2/XZ/ZSTD,LEVEL=FAST/NORMAL/BEST,FORMAT=AUTO/Z32/Z64,ENCODE=UTF8/DOS/ASCII,COMMENT='str',NOXFLD,STREAM)

#### Description

Can be used to store one or more files in a ZIP archive. Files are compressed using the deflate algorithm unless another algorithm is set with the ALGO parameter. The compression level, the character set for filenames stored in the archive and a custom comment can be set. The supported compression algorithms are DEFLATE (default), BZIP2 and COPY (no compression). Note that many compression utilities do not support decompression of files not compressed with DEFLATE. If a file written to the ZIP archive is not compressible, it is stored in COPY mode automatically to avoid unnecessary CPU utilization.

If compression or encryption has been enabled via the COMPRESS or ENCRYPT overlay of the surrounding WRITE.*() object (e.g. WRITE.BIN(COMPRESS.GZIP())), the resulting stream is written to the ZIP archive as-is, without attempting further compression (i.e. the resulting ZIP file has a .gz member that was written in COPY mode).

By activating the APPEND switch, new members are appended to the ZIP file and existing members are replaced. If the REMAIN switch is enabled on append, an error occurs if a member already exists in the archive. If the APPEND switch is not used, but the REMAIN flag is set and the archive already exists, the archive is not overwritten.

If this object is used to write records (WRITE.RECORD(ARCHIVE.ZIP())), each record is prepended with a 4 byte record length field in little endian (length field itself not included), conforming to PKWARE APPNOTE. If the PRNCONTROL parameter is set to RETAIN, then ASA or machine control characters are part of the record and included in the length field. When using WRITE.BINARY() or WRITE.CHAR() to write ZIP archives in combination with record-based input, the length field format can be configured, including dropping record length information.

Archives larger than 4 GiB or containing more than 65535 members are supported with 64 bit ZIP archive support which some ZIP tools are not capable to read. Creation of 64 bit ZIP archives can be prevented by enforcing the 32 bit format. In this case, an error occurs when reaching one of the limits of the original ZIP format. The 64 bit format might be enforced too. If no format or 'FORMAT=AUTO' is given a backward compatible 32 bit format with 64 bit extensions for files smaller than 4 GiB are written. This format will result in a warning by 7z since version 19 and can be ignored. To prevent this warning Z32 or Z64 bit format must be enforced.

Writing ZIP archives requires repositioning within the file which is not supported for PDS(E) members on z/OS. Hence, ZIP archives cannot be written to a PO member. You can copy ZIP files to a PO member and read the ZIP archive from there, but you cannot write to it. You also cannot use the REMOVE switch when reading from a PO member, because this requires rewriting the ZIP archive.

With the switch STREAM the streamed version of the ZIP file format is enforced while writing. This will improve performance if only sequential I/O is required and a record oriented dataset is used. If no format is given the Zip64 format will be written in this case. With 'FORMAT=Z32' the older version of a ZIP archive can be enforced if the stream doesn't exceed 4 GiB.

With the switch NOXFLD you can deactivate the write of the FLAM private extra field to the local and directory file header. If this is used the ZIP file doesn't contain this private extension and the reconstruction of files with FLAM to the original format will fail, because not all required information are available for it.

#### Arguments

- `STRING: MEMBER='str' - File name for header [from origin]`
- `NUMBER: ALGO=COPY/DEFLATE/BZIP2/XZ/ZSTD - Compression algorithm [DEFLATE]`
  - `COPY - Store uncompressed`
  - `DEFLATE - DEFLATE algorithm (GZIP)`
  - `BZIP2 - BZIP2 algorithm (BZIP2)`
  - `XZ - LZMA algorithm (XZ)`
  - `ZSTD - ZSTD algorithm (ZSTD)`
- `NUMBER: LEVEL=FAST/NORMAL/BEST - Compression level [AUTO]`
  - `FAST - Fastest compression`
  - `NORMAL - Optimal compression`
  - `BEST - Highest compression`
- `NUMBER: FORMAT=AUTO/Z32/Z64 - Choose the format to write [AUTO]`
  - `AUTO - As needed (32 bit for small files and 64 for large ones)`
  - `Z32 - Always 32 bit format (old)`
  - `Z64 - Always 64 bit format (modern)`
- `NUMBER: ENCODE=UTF8/DOS/ASCII - Select encoding for file names and comments [UTF-8]`
  - `UTF8 - UTF-8 encoding (recommended)`
  - `DOS - IBM437 encoding (old 8 bit ASCII of ZIP files))`
  - `ASCII - IBM367 encoding (US ASCII (only 7 bit subset of UTF-8 and IBM437))`
- `STRING: COMMENT='str' - Define a comment for this ZIP archive`
- `SWITCH: NOXFLD - Don't write extra fields into the member header [FALSE]`
- `SWITCH: STREAM - Write streamed ZIP file, uses only sequential I/O, no seek [FALSE]`