REC

Synopsis

HELP:   Write a file record-oriented (mainly mainframe world)
TYPE:   OBJECT
SYNTAX: REC(RECFMT=NONE/BIN/TXT/TXT-ASA/TXT-MCC/DLM/DLM-ASA/DLM-MCC/VAR/VAR-ASA/VAR-MCC/FIX/FIX-ASA/FIX-MCC/VAR-REL/VAR-REL-ASA/VAR-REL-MCC/FIX-REL/FIX-REL-ASA/FIX-REL-MCC/F/FA/FM/FS/FSA/FSM/FB/FBA/FBM/FBS/FBSA/FBSM/FE/FEA/FEM/FK/FKA/FKM/FR/FRA/FRM/U/UA/UM/V/VA/VM/VS/VSA/VSM/VB/VBA/VBM/VBS/VBSA/VBSM/VE/VEA/VEM/VK/VKA/VKM/VR/VRA/VRM/ORG,RECLEN=num,NET.{},NAME/FILE='str'/STREAM/DUMMY,MODE=STOP/APPEND/OVERWRITE,EMPTY=INFO/WARNING/ERROR/DELETE,FALLOC(),REMOVE,RENAME='str',REMAIN,NOMKDIR,APPEND,FLUSH,RECMOD=STOP/CUT/WRAP/SKIP,PRNCTR=DETACH/RETAIN/ERASE/REPLACE,RPLFFD[=num],RECCNT=num,LENFMT.{},SUPPAD,PADCHR='bin'/BINARY-ZERO/ASCII-BLANK/EBCDIC-BLANK/UTF08-BLANK/UTF16BE-BLANK/UTF16LE-BLANK/UTF32BE-BLANK/UTF32LE-BLANK,CHRSET=NONE/SYSTEM/ASCII/UCS1/UTF8/EBCDIC/UCS2BE/UTF16BE/UCS2LE/UTF16LE/UCS4BE/UTF32BE/UCS4LE/UTF32LE/LOCAL,RECDLM='bin'/CR-ASCII/LF-ASCII/NL-ASCII/CRLF-ASCII/CR-EBCDIC/LF-EBCDIC/NL-EBCDIC/CRLF-EBCDIC/CR-UTF08/LF-UTF08/NL-UTF08/CRLF-UTF08/CR-UTF16BE/LF-UTF16BE/NL-UTF16BE/CRLF-UTF16BE/CR-UTF16LE/LF-UTF16LE/NL-UTF16LE/CRLF-UTF16LE/CR-UTF32BE/LF-UTF32BE/NL-UTF32BE/CRLF-UTF32BE/CR-UTF32LE/LF-UTF32LE/NL-UTF32LE/CRLF-UTF32LE,ACSTIM=num,MODTIM=num/ORIGINAL,NOSPAN,ATTRIB(),PREPRO[()...],POSTPRO/PSTPRO[()...],ADDEXT='str')

Description

This object defines the record-oriented write operation for files. This method writes each data list entry as one record to a data set. You can define the behavior (STOP/CUT/WRAP) if the record is longer than the accepted record length for this file. You can activate the suppression of padding characters and set the padding character. You can define the file organization, block size, record format, add a delimiter behind each record and a lot of other parameters (see below).

A dynamic allocation of the file can be used. This is very powerful and simplifies the generation of files on mainframe systems. The default values for this dynamic allocation depend on the data itself and the original file where the data came from. For example, if you have read an FB80 data set with a GZIP data stream which was formatted based on delimiters in text records and you write it to a file on z/OS without any further parameters, then a PS-VB data set (not FB) with data dependent records is allocated with the correct size. If the result of the decompression is still binary data, then still a PS-FB80 dataset will be allocated. But you can also define other parameters for the file allocation. In this case, the data is converted to this format as good as possible.

On non-mainframe platforms (Windows, Unix, ...), the record I/O module can be used to write records terminated by a delimiter (TXT/DLM) or in a fixed or variable length format. For variable format, the length format must be defined. The default in this case is a 4 byte integer in the platform-dependent endianness. This default conforms to FILEDATA=RECORD for USS on a z/OS mainframe system.

If you chose a host record format for the write on a non-record-oriented Attributes (length, slot number of RRDS, print control character) are stored in front of each record on non-record-oriented systems. Example: If you read a RRDS with print control characters (FRA) and you write this on UNIX as record format VRA to a file, the file format looks like this:

If you chose a host record format for writing on a non-record-oriented system, then the length (only if it is a variable format) and other attributes (slot number, print control character) are stored in front of the data. Here is an example for VRA (variable, relative record format with ASA print control character):

    LLLLnnnnnnnnCdddd..dddd
    LLLLnnnnnnnnCdddd..dddd
    LLLLnnnnnnnnCdddd..dddd
    ...
    ...
    ...
    LLLLnnnnnnnnCdddd..dddd
    LLLLnnnnnnnnCdddd..dddd

Where LLLL is the record length, nn...nn is the slot number, C is the print control character and dd..dd is the record data. To read such a file on the UNIX system, the record format and length format (if you write with defaults, you can read with defaults) must be defined correctly.

This feature allows to unload an RRDS to a WINDOWS or UNIX system and to load this RRDS again with same records and gaps between. Each supported record format has a corresponding representation on non-mainframe systems. This means this unload and load is possible for each kind of data set type of mainframe systems.

To retain the modification time of the original file, the modtime parameter can be set to ORIGINAL.

Logical record description at the object

RECFORMAT and RECLENGTH at this object (RECFMT and RECLEN at FIO.REC) describe the LOGICAL side: how the data is cut into records before it is handed to the file layer. The same two parameters inside FALLOC() describe the PHYSICAL side: how the file or data set is created. Both lengths are net -- data only, without print control characters and without length fields.

  write.record(file='DD:OUTPUT' recformat=TXT falloc(recf=FB recl=80))

writes text records with their delimiter into a data set described as FB80, while

  write.record(file='DD:OUTPUT' recformat=FIX reclength=80)

writes fixed records of 80 bytes into a statically allocated data set, where there is no allocation to describe at all. Giving only the FALLOC() pair is the spelling of every release before 5.2.1 and keeps working unchanged. The FALLOC() manual page lists the merge rules and the combinations that are refused.

Records longer than the record length together with a delimiter

RECMODE says what happens to a record that does not fit into the record length. With RECDELIM the record has to be assembled in a buffer before it is written, so the mode is applied first: SKIP drops the record, and CUT shortens it so that the delimiter still fits into the record. WRAP has no answer that works from a buffered copy, and the default STOP has none either -- both are refused with a message naming the lengths. Without RECDELIM, a key disposition or retained print control no buffer is involved and every record mode works for any record length.

Automatic qualifier extension on write (ADDEXT)

The addext parameter accepts a suffix string. When set, FLAM builds a record-format qualifier from the effective write parameters and appends it -- together with the suffix -- to the output filename before the file is created:

  write.record(file='output', recf=FB, lrecl=80, addext='.bin')
  -> creates output.FB80.bin

The qualifier encodes the same information that read.record() reads back automatically (AUTODET) when it encounters the same filename. This makes write/read round-trips self-documenting and parameter-free on the read side.

A single INFO-level message is emitted when the extension is appended:

  FIOREC-OPNW : ADDEXT: appended '.FB80.bin' to output filename 'output'

The qualifier is built from the following write parameters:

When RECFM and LFM qualifiers are both present the result is combined into a single qualifier pair: .VB4096.LFM32B.

The addext suffix may start with a dot; a leading dot is merged with the trailing dot of the qualifier to avoid a double separator.

On z/OS MVS host datasets (names starting with a subsystem prefix ':') the ADDEXT extension is not applied.

Arguments