DFSORT Include Writing Constants

DFSORT INCLUDE statement DFSORT INCLUDE: Numeric tests

Advertisements


There are different formats to specify strings, hexadecimal strings, and decimal numbers in DFSORT.

The formats for writing character strings, hexadecimal strings, and decimal numbers are shown below.


Character strings

The format for writing a character string is: C’x...x’ where x is an EBCDIC character.


Hexadecimal strings

The format for writing a hexadecimal string is: X’yy...yy’ where yyis a pair of hexadecimal digits.


Decimal numbers

The format for writing a decimal number is: n...n or ±n...n where n is a decimal digit.


Syntax:

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

Let’s discuss in detail.


nameDescription
Field1 starting positionStarting position of field1 to be compared
Field1 LengthLength of the field1 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
ConstantSpecifies the constant to be compared

Example:

From the below data, filter the records having name Srinivas. The NAME starts from 11th and ends at 28th column in the file.


Input: MTH.SORT.INPUT

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00002     Srinivas            Employee                                             
test      test                test
00001     pawan kumar         student                                              
******************************** Bottom of Data ********************************

Input Record Layout:

01 INPUT-REC.
	05 ID			PIC X(05).
	05 FILLER		PIC X(05).
	05 NAME			PIC X(15).
	05 FILLER		PIC X(05).
	05 OCCUPATION 		PIC X(10).
	05 FILLER		PIC X(40).

Job:

000100 //Jobcard
000400 //**********************************************************************
000500 //*                                                                     
000510 //* SORT TO WRITE CHARACTERS/NUMERIC IN INCLUDE CONDITION               
000520 //*                                                                     
000600 //**********************************************************************
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 *                                                         
002410      SORT FIELDS=COPY                                                   
002420      INCLUDE COND=(11,15,CH,EQ,C'Srinivas')        
003400 /*                                                                      
****** **************************** Bottom of Data ****************************

Output:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* TOP OF DATA **********************************
00002     Srinivas            Employee                                             
******************************** BOTTOM OF DATA ********************************

Explaining Solution:

  1. As a first step, need to get the position of the NAME in the file.
  2. The NAME starting from 11th and ends at 25th column as per the input record layout provided. So the length of NAME field is 15.
  3. As a Second step, need to get the type of the NAME.
  4. From the Input record layout declaration, NAME field is alpha-numeric. So the type is character (CH).
  5. Lastly, the job requirement is to filter the data with the NAME as Srinivas. So the constant is "Srinivas".
  6. The INCLUDE condition for the above requirement with all data gathered is

  7. INCLUDE COND=(11,15,CH,EQ,C'Srinivas')  

  8. The above condition specifies that include the records where the NAME is "Srinivas" and copied to output file.
  9. The output would have the records which contains the NAME as "Srinivas" from 11th position.

DFSORT INCLUDE statement DFSORT INCLUDE: Numeric tests

Advertisements