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 INCLUDE 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

In order to deal with conditions which involves date comparison, OMIT statement is provided with few Date constants which can help us to specify and use current date, past date or any future dates.

To specify current date one can use below constants based on the format needed:-

System provided constant Format of date
DATE1P +YYYYMMDD
DATE2P +YYYYMM
DATE3P +YYYYDDD

  • All constants i.e. DATE1P, DATE2P and DATE3P refers to current date, current month and current day of the year respectively
  • Past date can be referred by subtracting any number of days from constant i.e. (DATE1P-1 refers to yesterday, DAT1P-2 refers to Day before yesterday and so on). Similarly one can also subtract number of months from DATE2P and days from DATE3P.
  • Future date can be referred by adding any number of days to constant i.e. (DATE1P+1 refers to tomorrow, DAT1P+2 refers to Day after tomorrow and so on). Similarly, one can also add number of months from DATE2P and days from DATE3P.

Note: Removing the end letter ‘P’ from date constant will allow us to use date constant as character value i.e. DATE1 equals to C’20190110’

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,OR,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)



Advertisements






© copyright mainframebug.com
Privacy Policy