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_positionSpecifies the starting position of field1 to be compared
field1_lengthSpecifies the length of the field1 to be compared
field1_formatSpecifies the format of the field1. Use BI (Binary) for Alphanumeric tests
relational_operatorused 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
ConstantSpecifies 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 -

  1. It incrases the speed of sorting by removing unwanted records with an INCLUDE or OMIT statements before sorting, copying or merging.
  2. 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.
  3. INCLUDE or OMIT statements should not be coded together unless the output files are different.
  4. Logical operators AND and OR can be used to combine two or more conditions with logically.