Sunday 19 May 2019

SORT INCLUDE and OMIT Statements | JCL INCLUDE | JCL OMIT Example.

OMIT JCL

SORT INCLUDE and OMIT statements


Welcome back to today's session on "JCL SORT Tricks". In this session, you'll learn the basics of JCL SORT INCLUDE and JCL SORT OMIT control statements. These are imperative control statements that are used to improve the efficiency of a SORT job. You will go through the SORT INCLUDE example and the SORT OMIT example. 


Let's get started with an introduction to DFSORT utility (i.e. JCL SORT utility).

  

JCL Tutorial - Agenda. 

  • Introduction. 
  • What is JCL SORT INCLUDE?
  • JCL SORT INCLUDE Syntax.
  • What is JCL SORT OMIT?
  • SORT INCLUDE Example.
    • Include COND in JCL SORT for Numeric. 
    • Multiple Include COND in JCL. 
  • SORT OMIT Example.
    • Omit Cond in JCL for Numeric. 
  • Conclusion.


Introduction. 

Every day millions of jobs (i.e. JCL's) run on the mainframe to sort or merge data from different files. These mainframe jobs use JCL SORT Utility (i.e. DFSORT/SYNCSORT) to include or omit records from the file based on selection criteria. The sorted or merged file is further processed by different batch processes to produce the desired output.   

SORT INCLUDE and SORT OMIT are two such parameters that are used to improve the efficiency of the JCL SORT utility and these parameters provide some more processing capabilities. 

What is the JCL SORT INCLUDE statement?  

JCL SORT INCLUDE statement is used to specify the inclusion criteria in the JCL sort utility. You can use an INCLUDE statement if you want specific records to appear in the output data set. INCLUDE control statement improves the SORT efficiency and provides more processing capability. 

JCL SORT INCLUDE Syntax. 

The following is the syntax of the SORT INCLUDE statement: 

INCLUDE COND=(field,comparison,{field }, [ {AND}, ]…)
              {constant} {OR }

A logical expression is a logical combination of one or more relational conditions based on fields in the input record, and it can be articulated in the following way at a high level.

JCL SORT INCLUDE Syntax.

JCL SORT INCLUDE Syntax.


What is the JCL SORT OMIT statement?

JCL SORT OMIT statement is used to specify the exclusion criteria in the JCL sort utility. You can use an OMIT statement if you want to exclude records from the output data set. OMIT control statement improves the SORT efficiency by reducing the number of input records and provides more processing capability. 

JCL SORT OMIT Syntax?

The following is the syntax of the SORT OMIT COND statement: 
 
OMIT COND=(field,comparison,{field }, [ {AND}, ]…)
           {constant} {OR }

JCL SORT OMIT Statement, OMIT COND=

JCL SORT OMIT Statement


Important Points: 
  • field:: A field to be used in a comparison. The field is specified as in the SORT or MERGE statement: position, length, format.
  • comparison:: One of these comparison operators:
                 EQ:- Equal GE Greater than or equal to
                NE:- Not equal LT Less than
               GT:- Greater than LE Less than or equal to
  • constant:: A literal value in one of these formats:
             Decimal         5               +104               -39
            Character      C’CA’      C’JONES’      C’X24'
            Hexadecimal    X’00'       X’F9F9'         X’40404040'
  • AND  and OR:: Operator will be used to include additional conditions.

Important Point: You can use either an INCLUDE statement or an OMIT statement as per business requirement in the same DFSORT run, but not both.


Format Code      |    Description
     CH               Character. 
     AQ                     Character with alternate collating sequence
     ZD                     Signed zoned decimal
     PD                     Signed packed decimal
     PD0                      Packed decimal with sign and first digit ignored
     FI                            Signed fixed-point
     BI                     Unsigned binary
     AC                     ASCII character


Now, Let's discuss the following JCL SORT INCLUDE Example and JCL SORT OMIT Example in detail:

#1.  SORT INCLUDE Example: 

In the following JCL, SORT included an example, only the records having an 'A' in the first byte will be included.

//RCTX021D JOB (JOB CARD.....)
//STEP010  EXEC PGM=SORT      
//SYSOUT   DD SYSOUT=*             
//SORTIN   DD DSN=TP01.PAYROL.FILE,DISP=SHR 
//SORTOUT  DD SYSOUT=* 
//SYSIN DD *
  INCLUDE COND=(1,1,CH,EQ,C'A'),
  SORT FIELDS=(1,14,CH,A)
/* 

#2. INCLUDE COND in SORT JCL for numeric value.

The following JCL SORT INCLUDE example includes only the records with a packed-decimal value in bytes 72-76 that’s greater than or equal to 1000.

//RCTX022D JOB (JOB CARD.....)
//STEP010  EXEC PGM=SORT      
//SYSOUT   DD SYSOUT=*             
//SORTIN   DD DSN=TP01.TAX.FILE,DISP=SHR 
//SORTOUT  DD SYSOUT=* 
//SYSIN DD *
  INCLUDE COND=(72,5,PD,GE,1000),
  SORT FIELDS=(1,14,CH,A)
/* 

#3 INCLUDE COND in SORT for packed decimal.

The following SORT INCLUDE only the records with a packed-decimal value in bytes 72-76 that’s greater than or equal to 1000 or less than 10.

//RCTX022D JOB (JOB CARD.....)
//STEP010  EXEC PGM=SORT      
//SYSOUT   DD SYSOUT=*             
//SORTIN   DD DSN=TP01.TAX.FILE,DISP=SHR 
//SORTOUT  DD SYSOUT=* 
//SYSIN DD *
  INCLUDE COND=(72,5,PD,GE,1000,OR,72,5,PD,LT,10),
  SORT FIELDS=(1,14,CH,A)
/* 

#4 Multiple INCLUDE COND in SORT.

The following example explains, how you can include multiple include conditions in JCL SORT.   
INCLUDE FORMAT=CH,
   COND=((5,1,EQ,8,1),&,
        ((20,1,EQ,C'A',&,30,1,FI,GT,10),|,
         (20,1,EQ,C'B',&,30,1,FI,LT,100),|,
         (20,1,NE,C'A',&,20,1,NE,C'B')))

Note: & - represent AND logical operator.

#5 OMIT COND in JCL SORT. 

The following example illustrates, how you can use OMIT COND in JCL SORT to exclude records from the SORT processing (i.e. OMIT the records that have an A in byte 1.)

OMIT COND=(1,1,CH,EQ,C'A')

#6 OMIT COND in JCL for numeric.

The following example illustrates, how you can use OMIT COND in JCL SORT to exclude records from the SORT processing.

OMIT COND=(27,1,CH,EQ,C'D',&,
          (22,2,BI,SOME,X'C008',|,
           28,1,BI,EQ,B'.1....01'))

Youtube - JCL SORT utility. 



Conclusion. 

Finally, this concludes today's "SORT INCLUDE and OMIT Statements" tutorial. In this tutorial, you learn the basics of both JCL SORT INCLUDE and JCL SORY OMIT Statements and how these control statements can be used to improve the efficiency of the JCL SORT utility. Do check out more tutorials on JCL SORT, COBOL, CICS Tutorial, and JOB Interview Questions. 
 
Subscribe to Topictrick & Don't forget to press THE BELL ICON to never miss any updates. Also, Please visit mention the link below to stay connected with Topictrick and the Mainframe forum on - 

► Youtube
► Facebook 
► Reddit

Thank you for your support. 
Mainframe Forum™

1 comment:

New In-feed ads