OMIT: Writing constants
OMIT: Writing constants
Summary
- There are different formats to specify strings, hexadecimal strings, and decimal numbers in DFSORT. The formats for writing character strings, hexadecimal strings, and decimalnumbers 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 -
OMIT COND=(Field1 starting position, Field1 Length,
Field1 format, Relational Operator, constant)
Field1 starting position | Starting position of field1 to be compared |
Field1 Length | Length of the field1 to be compared |
Field1 format_type | Format of the field1 like CH, PD, BI etc,. |
Relation operator | Relational operators like GT, EQ, NE, LT etc,.
|
Constant | Specifies the constant to be compared |
Example -
Scenario - From the below data, filter the records not having name Srinivas. The NAME starts from 11th and ends at 28th column in the file.
Input File - 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).
JCL -
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//Job-card
//**********************************************************************
//*
//* SORT TO WRITE CHARACTERS/NUMERIC IN OMIT CONDITION
//*
//**********************************************************************
//STEP01 EXEC PGM=SORT
//SORTIN DD DSN=MTH.SORT.INPUT,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OMIT COND=(11,15,CH,EQ,C'Srinivas')
/*
**************************** Bottom of Data ****************************
Output -
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* TOP OF DATA **********************************
test test test
00001 pawan kumar student
******************************** BOTTOM OF DATA ********************************
Explaining Example -
- As a first step, need to get the position of the NAME in the file.
- The NAMEs starting from 11th and ends at 25th column as per the input record layout provided. So the length of NAME field is 15.
- As a Second step, need to get the type of the NAME.
- From the Input record layout declaration, NAME field is alpha-numeric. So the type is character (CH).
- Lastly, the job requirement is to ignore the data with the NAME as Srinivas. So the constant is "Srinivas".
- The OMIT condition for the above requirement with all the data gathered is -
OMIT COND=(11,15,CH,EQ,C'Srinivas')
- The above condition specifies that ignore the records where the NAME is Srinivas and remaining records copied to output file.
- The output would have the records where the NAMEs are not Srinivas from 11th position.
Note! The matching text is always case sensitive and should use the same case while matching.