Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 8: JCL Sort & Merge


OMIT Statement

OMIT statement function exactly opposite of INCLUDE statement. INCLUDE and OMIT are mutually exclusive commands. OMIT statement is used to reject records which meets specified conditions. Please refer previous section ‘INCLUDE statement’ to understand what all conditions can be handled with OMIT Statement

Syntax:-

Let’s see example:-

Input file:-

----+----1----+----2----+----3----+----4----+----5 88888JOHN PURCHASING 08000 11111AKSHAY HR 10000 55555SMITH R&D 25000 44444STEVE ADMIN 20000 33333VIJAY FINANCE DEPT 24000 77777VIJAY FINANCE DEPT 30000 44444STEVE HR 20000

Requirement: Copy records that does not have ‘44444’ in position 1 to 5

JCL Code:

//SORTSTEP EXEC PGM=SORT //SORTIN DD DSN=DEPT.EMPL.DATA.INPUT, // DISP=SHR //SORTOUT DD DSN=DEPT.EMPL.DATA.OUTPUT1, // DISP=(,CATLG,DELETE), // DCB=(RECFM=FB,LRECL=50,BLKSIZE=0), // UNIT=TEST,SPACE=(CYL,(50,10),RLSE) //SYSOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SYSIN DD * SORT FIELDS=COPY OMIT COND=(1,5,CH,EQ,C'44444') /*

Output file:-

----+----1----+----2----+----3----+----4----+----5 88888JOHN PURCHASING 08000 11111AKSHAY HR 10000 55555SMITH R&D 25000 33333VIJAY FINANCE DEPT 24000 77777VIJAY FINANCE DEPT 30000

Using Date Constant in OMIT statement

For more details on Date constant, please refer section ‘Using Date Constant in INCLUDE statement’. Here we will focus only on example

Example 1:-

Input file:

----+----1----+----2----+----3----+----4----+----5 11111AKSHAY HR 10000 20250811 44444STEVE HR 20000 20120811 11111AKSHAY HR 10000 20150811 55555SMITH R&D 25000 20150811 44444STEVE ADMIN 20000 20160805 77777VIJAY FINANCE DEPT 30000 20160815 44444STEVE HR 20000 20240811

Requirement: Omit those records from copying which has date less than or same as current date (let’s assume current date is 2016-Aug-11)

SYSIN Control card:

//SYSIN DD * SORT FIELDS=COPY OMIT COND=(43,8,ZD,LE,DATE1P) /*

Output file:

----+----1----+----2----+----3----+----4----+----5 11111AKSHAY HR 10000 20250811 77777VIJAY FINANCE DEPT 30000 20160815 44444STEVE HR 20000 20240811

Example 2:-

Input file:

----+----1----+----2----+----3----+----4----+----5 11111AKSHAY HR 10000 20250811 44444STEVE HR 20000 20120811 11111AKSHAY HR 10000 20150811 55555SMITH R&D 25000 20150811 44444STEVE ADMIN 20000 20160805 77777VIJAY FINANCE DEPT 30000 20160815 44444STEVE HR 20000 20240811

Requirement: OMIT those records from copying which has date between CURRENT DATE +/- 10 days (let’s assume current date is 2016-Aug-11)

SYSIN Control card:

//SYSIN DD * SORT FIELDS=COPY OMIT COND=(43,8,ZD,LE,DATE1P+10,AND,43,8,ZD,GE,DATE1P-10) /*

Output file:

----+----1----+----2----+----3----+----4----+----5 11111AKSHAY HR 10000 20250811 44444STEVE HR 20000 20120811 11111AKSHAY HR 10000 20150811 55555SMITH R&D 25000 20150811 44444STEVE HR 20000 20240811

Tip: If input date format is YYYY-MM-DD, use DATE1(-) in place of DATE1.

Example 3:-

Input file:-

----+----1----+----2----+----3----+----4----+----5 11111AKSHAY HR 10000 2025-08-11 44444STEVE HR 20000 2012-08-11 11111AKSHAY HR 10000 2015-08-11 55555SMITH R&D 25000 2015-08-11 44444STEVE ADMIN 20000 2015-08-11 77777VIJAY FINANCE EPT 30000 2024-08-11 44444STEVE HR 20000 2024-08-11

Requirement: OMIT those records from copying which has date greater than or same as current date. Here date format is YYYY-MM-DD (let’s assume current date is 2016-Aug-11)

SYSIN Control card:

//SYSIN DD * SORT FIELDS=COPY OMIT COND=(43,8,CH,GE,DATE1(-)) /*

Output file:

----+----1----+----2----+----3----+----4----+----5 44444STEVE HR 20000 2012-08-11 11111AKSHAY HR 10000 2015-08-11 55555SMITH R&D 25000 2015-08-11 44444STEVE ADMIN 20000 2015-08-11

Below are few more requirement which can be addressed using SORT OMIT command:

Requirement 1: OMIT those records from copying which has one of the values (‘STEVE’,’VIJAY’,’SMITH’) in position 6 to 10

SYSIN Control card:

OMIT COND=(6,5,SS,EQ,C'STEVE,VIJAY,SMITH')

Requirement 2: OMIT those records from copying which has value at position 72-76 greater than or equal to 1000 or less than 10

SYSIN Control card:

OMIT COND=(72,5,PD,GE,1000,OR,72,5,PD,LT,10)

Requirement 3: OMIT those records from copying which has valid numeric data in specified fields

SYSIN Control card:

OMIT COND=(50,10,FS,EQ,NUM)

Requirement 4: OMIT those records from copying which has valid numeric data in specified fields

SYSIN Control card:

OMIT COND=(50,10,FS,EQ,NUM)






© copyright mainframebug.com
Privacy Policy