The rules language can also produce and write records. The records use symbolic fields and literal strings to produce fixed format records.
The DEFREC statement defines a record used in the rules language. During rules and procedure processing, the SET and ISSUE action statements use the WRITEREC parameter to actually write the record. When the rules are being processed in environments that do not allow file I/O, the records are scheduled to be written to DD statements allocated in the DIF started task, or written to an APPC network node. For non-authorized environments, the records are written to DD statements in the current job step.
Building Records - The DEFREC statement builds the record with the use of FIELD substatements. The FIELD substatements can use symbolic fields or literal values. The LENGTH parameter on the DEFREC defines the logical record size. If not specified, the record length will be established using the last field definition in the record.
The fields can be placed at specific offsets within the record with the POSITION parameter. If no position is specified, the field will be added immediately after the previous field. By default, the compiler obtains the field lengths from the symbolic field, or calculates the length of a literal string. The length can be specified on the field definition with the LENGTH parameter.
The records can contain both character fields and numeric fields. Numeric fields can be specified as binary or packed. If TRANSLATE(ASCII) has been specified, the character fields in the record will be translated to ASCII before the record is written.
The following example illustrates the use of the DEFREC and FIELD statements. The @ACTREC record length is fixed at 245 bytes long, and will be initialized to blanks. The fields that define the record use implicit offsets and lengths - the compiler will calculate the position and length of each field. During program execution, when a rule definition requests a WRITEREC(@ACTREC), the record will be built and written to the RTMDB DD statement.
DEFREC @ACTREC INIT(BLANKS) DDNAME(RTMDB) LEN(245) FIELD &SYSID
FIELD &CURLDATE FIELD &CURDAY FIELD &CURTIME FIELD &JOBNAME FIELD "ACTION " FIELD &VOLSER FIELD &DSNAME FIELD &ENV
FIELD &ENVS FIELD &DADSM_RC FIELD &RUSER