DFSORT Omit Statement

DFSORT INCLUDE: Allowable comparisons DFSORT OMIT: Writing constants


Omitting recordscan ignore the specific set of records which satisfies the condition provided.

In this scenario, all records other than the records which satisfy the condition specified will be copied to output file.

EXCLUDE control statement is used to specify the selection criteria.

Syntax-1: Comparing with a constant

OMIT COND=(Field1 starting position, Field1 Length, Relational Operator, constant)

Syntax-2: Comparing with another field

OMIT COND=(field1 starting position, field1 Length, field1 format_type, Relational Operator, 
		field2 starting position, field2 Length,field2 format_type)

Let’s discuss in detail.

Field1 starting positionStarting position of field1 to be compared
Field1 LengthLength of the field to be compared
Field1 format_typeFormat of the field1 like CH, PD, BI etc,.
Relation operatorRelational operators like GT, EQ, NE, LT etc,.

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 positionStarting position of field2 which is to be compared with Field1
field2 LengthLength of field2 which is to be compared with field1
Field2 Format_typeFormat of the field2 like CH, PD, BI etc,.

Example:Comparing with a constant

From the below data, filter the records not having the id is 00001 and the ID starts from 1st and ends at 5th column in the file


********************************* Top of Data **********************************
00002     Srinivas            Employee                                             
test      test                test
00001     pawan kumar         student                                              
******************************** Bottom of Data ********************************

Input Record Layout:

	05 ID			PIC X(05).
	05 FILLER		PIC X(05).
	05 NAME			PIC X(15).
	05 FILLER		PIC X(05).
	05 FILLER		PIC X(40).


000100 //Jobcard
000500 //**********************************************************************
000600 //*                                                                     
000700 //* SORT TO WRITE NUMBERIC TEST IN OMIT CONDITION                    
000800 //*                                                                     
000900 //**********************************************************************
001100 //STEP01   EXEC PGM=SORT                                                
001300 //SORTIN   DD DSN=MTH.SORT.INPUT,DISP=SHR                      
001800 //SORTOUT  DD SYSOUT=*                                                  
001900 //SYSOUT   DD SYSOUT=*                                                  
002400 //SYSIN    DD *                                                         
002401      OMIT COND=(1,05,CH,EQ,C'00001')
002410      SORT FIELDS=COPY                                                   
003400 /*                                                                      
****** **************************** Bottom of Data ****************************


********************************* TOP OF DATA **********************************
00002     Srinivas            Employee                                             
test      test                test
******************************** BOTTOM OF DATA ********************************

Explaining Solution:

  1. As a first step, need to get the position of the ID in the file.
  2. The names starting from 1st position and ends at 5th position as per the input record layout provided. So the length of IDfield is 5.
  3. As a Second step, need to get the type of the ID.
  4. From the Input record layout declaration, ID field is alpha-numeric. So the type is character (CH).
  5. Lastly, the job requirement is to ignore the data with the ID as 00001and other records should be copied. So the constant is 00001.
  6. The OMIT condition for the above requirement with all the data gathered is
  7. OMIT COND=(1,05,CH,EQ,C'00001')
  8. The above condition specifies that ignore the records where the ID is00001 and other records which are not satisfied the condition copied to output file.
  9. The output would have the records where the IDs not equal to00001 at first 5 positions.

DFSORT INCLUDE: Allowable comparisons DFSORT OMIT: Writing constants