OMIT Statement


The OMIT control statement is used to exclude specific records from being processed based on certain conditions. It works the opposite way of the INCLUDE statement, meaning the records that meet the specified conditions are omitted from the operation, while all other records are included. This allows us to filter out unwanted data based on character, numeric, or binary fields.

Syntax1 - Comparing with a constant

//SYSIN DD * 
    SORT FIELDS=COPY
    OMIT COND=(field1_starting_position, field1_length, field1_format,
		 relational_operator, constant)
/*

Syntax2 - Comparing with another field

//SYSIN DD * 
    SORT FIELDS=COPY
    OMIT COND=(field1_starting_position, field1_length, field1_format,
		 relational_operator, field2_starting_position, field2_length, field2_format)
/*
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. Format types include: CH (Character), ZD (Zoned Decimal), PD (Packed Decimal) and BI (Binary).
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
field2_starting_positionSpecifies the starting position of field2 to be compared
field2_lengthSpecifies the length of the field2 to be compared
field2_formatSpecifies the format of the field2.

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)

Scenario3 - Multiple Conditions Using AND

OMIT COND=(1,3,CH,EQ,C'ABC',AND,10,5,ZD,LE,500)

Scenario4 - Multiple Conditions Using OR

OMIT COND=(1,3,CH,EQ,C'XYZ',OR,5,4,CH,EQ,C'ABCD')