Purpose
To retain only records that satisfy certain conditions for further processing.
Format
|
criteria | = |
{DISCARDSHORT min_length } {DISCARDFIRST num_records} {DISCARDBLANK } {DISCARDAFTER num_records} {RETAINIF condition } |
Arguments
condition | The name of a condition defined in a /CONDITION option or a level 88 in a COBOL copybook supplied through a /datadictionaryoption. |
min_length | The minimum record length; records shorter than that length are discarded. |
num_records | The consecutive number of records to discard or to keep. |
Location
A /FILTER option can appear anywhere in the task definition; however, its position in relation to the first target option as well as any subsequent target options is important:
- For records filtered before the main task transformation, the /FILTER option must be listed before the first target option. (These source filters are applied before the main task transformation.)
- For records filtered for a specific target, the /FILTER option must be listed after the corresponding target option. When multiple targets exist, the /FILTER option applicable to a specific target must be listed after the option defining the target and before the option defining the next target, if any.
Notes
Source Record Filter
Only one source record filter can be specified per task.
Source Type and Source Filter Option Arguments
The option arguments that can be specified within a source filter are dependent upon the type of source.
The following /FILTER option arguments can be specified for file, buffer, and procedure sources only:
- DISCARDSHORT
- DISCARDFIRST
- DISCARDBLANK
- DISCARDAFTER
The RETAINIF option argument can be specifed for all sources.
Source Filter Option Arguments
- DISCARDSHORT - All records shorter than the specified minimum length are discarded.
- DISCARDFIRST - The specified number of records are discarded from the input stream starting from the first non-short record in the first input file. If the first file does not have enough records, records are discarded from the second file and subsequent files until the specified number of records are discarded.
- DISCARDBLANK - All blank records are discarded. A record is considered to be blank if either the record length is 0 or all bytes in the record are space characters.
- DISCARDAFTER - Only the specified number of records are collected for further processing. The RETAINIF sub-option, if specified, may further reduce the number of records.
- RETAINIF - Only records that satisfy the specified condition are retained for further processing.
Target Record Filters
Only one target record filter can be specified per target.
Target Filter Option Argument
Only the RETAINIF sub-option can be specified in the target filters.
Null condition
When the condition evaluates to NULL, it is equivalent to FALSE. The record is discarded.
Examples
/FILTER retainif in_usa
/FILTER retainif in_usa discardblank
/FILTER discardshort 3 discardfirst 10 discardafter 100
This option specifies that the records having recordlength less than 3 are discarded. Next, the first ten non-short records are discarded, and 100 records are considered for processing.