Including or omitting records
Including or omitting records
In this topic, we explains how to include or omit specific records during sorting, copying or merging process from from the input file to the output file.
INCLUDE Statement -
Including records can copy the specific set of records which satisfies the condition coded. INCLUDE statement is used for the above selection criteria.
Syntax - Comparing with a constant
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(field1_starting_position, field1_length, field1_format,
relational_operator, constant)
/*
Examples -
Scenario1 - Simple Character Comparison.
INCLUDE COND=(1,5,CH,EQ,C'HELLO')
Scenario2 - Numeric Comparison Using Zoned Decimal (ZD).
INCLUDE COND=(10,4,ZD,GT,1000)
OMIT Statement -
Omitting records can ignore the specific set of records which satisfies the condition coded. EXCLUDE statement is used for the above selection criteria.
Syntax - Comparing with a constant
//SYSIN DD *
SORT FIELDS=COPY
OMIT COND=(field1_starting_position, field1_length, field1_format,
relational_operator, constant)
/*
field1_starting_position | Specifies the starting position of field1 to be compared |
field1_length | Specifies the length of the field1 to be compared |
field1_format | Specifies the format of the field1. Use BI (Binary) for Alphanumeric tests |
relational_operator | used for condition comparison. The available operators are -
EQ Equal to NE Not equal to GT Greater than GE Greater than or equal to LT Less than LE Less than or equal to |
Constant | Specifies the constant to be compared |
Examples -
Scenario1 - Simple Character Comparison.
OMIT COND=(1,5,CH,EQ,C'HELLO')
Scenario2 - Numeric Comparison Using Packed Decimal (PD)
OMIT COND=(10,4,PD,GE,1000)
Points to Note -
- It incrases the speed of sorting by removing unwanted records with an INCLUDE or OMIT statements before sorting, copying or merging.
- Subset of the records can be selected from the input file by using INCLUDE or OMIT parameter on an OUTFIL statement to filter required records or exclude unwanted records, respectively.
- INCLUDE or OMIT statements should not be coded together unless the output files are different.
- Logical operators AND and OR can be used to combine two or more conditions with logically.