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 SCCACT DD statement.
DEFREC @ACTREC INIT(BLANKS) DDNAME(SCCACT) 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
FIELD name
BINARY
CHARACTER( options ) HEADER( 'text' )
KEY( data ) LENGTH( num )
MASK( dfsort_mask ) NUMERIC( type ) PACKED
POSITION( num )
REQUIRED( option ) TYPE( data )
name
Function: This is a required parameter. The name parameter associates
the field with a symbolic name or literal. If a symbolic name is specified, the name must begin with an ampersand (&). For example, the following field definition builds a field containing the current jobname.
FIELD &JOBNAME
When just part of a symbolic field is required, the displacement and length of the substring can be specified with the symbolic name. The displacement and length should be enclosed in parentheses, and be sepa-rated by a comma or blank. The parenthetical field must be concatenated with the symbolic field name. For example, the following symbolic name will be evaluated for the first three characters of the job name.
FIELD &JOBNAME(1,3)
The implicit length of a field definition using a symbolic will use the substring length if specified. Otherwise, the length will be obtained from the symbolic field used in the definition.
If the name does not start with an ampersand (&), the name is consid-ered a literal. If a literal begins with a double quote (") or single quote ('), the literal is considered a quoted string. For information about when to use a quoted string, examine Quoted strings.
The implicit length of the field is calculated from the length of the literal.
FIELD "ACTION "
Literals can also be numeric fields. If the literal is entirely numeric, the implicit length of the field is 4 bytes, and the literal is treated as a binary number.
Default: None
Format: Any symbolic name, or literal value.
Function: When BINARY has been specified on the field definition, a
numeric field will be saved as a binary field in the record. By default, the length of the field will be 4 bytes. However, the LENGTH parameter can be used to specify a length of 1-4 on binary fields.
Default: None
Format: BINARY
CHARACTER( option )
Function: The CHARACTER parameter is primarily used on FIELD
definitions using numeric fields. When CHARACTER has been specified, the field definition will convert a numeric field to a character format.
By default, a numeric field will be converted to a printable number with the leading zeroes removed (TRIM_ZEROES), and the number right justified in field (RIGHT_JUSTNUM).
The LEAVE_ZEROES option can be specified to leave the leading zeroes on the number. The LEFT_JUSTNUM option can be used to left justify the number in the field.
Default: CHARACTER(TRIM_ZEROES,RIGHT_JUSTNUM)
Format: TRIM_ZEROES or LEAVE_ZEROES
RIGHT_JUSTNUM or LEFT_JUSTNUM
HEADER( 'text' )
Function: This optional parameter is used by the SCC Monitor report
generation facility. By default, the field name is used as the columns title in the report. The HEADER parameter can be used to specify the column title for the report.
If the text in the new column title contains embedded blanks, the text must be enclosed in single quotes.
Default: None
Format: HEADER( 'text' )
KEY( data )
Function: This optional parameter is not used by Monitor. This
information is typically used to pass information to SCC Explorer when SCHEMA has been requested on the RECORD statement.
Default: None
Format: KEY( data ) where data is from 1 to 8 characters in length.
LENGTH( num )
Function: If a LENGTH parameter was not specified, the rules compiler
calculates the length of field based on the length associated with the symbolic name used in the field definition.
LENGTH should be used when the field should be truncated.
Default: None
Format: LENGTH ( num )
MASK( dfsort_mask )
Function: This optional parameter is used by the SCC Monitor report
generation facility. This parameter can be used to provide a formatting mask for the field. Note: For information about the available edit masks, examine the "edit mask patterns" table in the Sectioned Report section of the DISPLAY Operator in Chapter 6 of the DFSORT Application Programmers Guide (SC33-4035).
Default: None
Format: MASK( dfsort_mask )
NUMERIC( type )
Function: This optional parameter is used by the SCC Monitor and DLimit
report generation facilities. The NUMERIC parameter specifies how numeric FIELDs are to be generated. By default, DIF routines convert numeric fields to character before passing records to SORT. If NUMERIC( BINARY ) is specified, the field is passed as a binary number.
Default: NUMERIC(CHARACTER)
Format: BINARY or CHARACTER
PACKED
Function: When PACKED has been specified on the field definition, a
numeric field will be saved as a packed numeric field in the record. For PACKED fields, the LENGTH parameter should be specified to establish the length of the field.
Default: None
Format: PACKED
POSITION( num )
Function: If a POSITION parameter was not specified, the rules compiler
calculates the position (or offset) of the field based on the position and length of the previous field.
If the LENGTH parameter is not specified, the FIELD subparameters are analyzed to calculate the length of the record.
Default: None
Format: POSITION ( num ) where num is a value between 1 and the
logical record length defined by the LENGTH parameter on the DEFREC statement.
REQUIRED( option )
Function: The REQUIRED parameter on the DEFREC statement
establishes the default for the REQUIRED parameter on the associated FIELD statements. If a record contains required fields, the record will only be written when all required fields are available for substitution.
If a field has not been specified as required and the field is not available for substitution, the field will be initialized to blanks for character fields and 0 for numeric fields.
Default: REQUIRED(NO)
Format: YES or NO
TYPE( data )
Function: This optional parameter is not used by Monitor. This
information is typically used to pass information to SCC Explorer when SCHEMA has been requested on the RECORD statement.
Default: None
Format: TYPE( data ) where data is from 1 to 8 characters in length.