JCL

SAVE discarded records using SORT

Record Selection for Output File can be done using STARTREC, ENDREC, INCLUDE/OMIT, SAVE Parameters. Use SAVE to include records for OUTFIL processing that have not been included in any other OUTFIL group. If SAVE is specified on more than one OUTFIL group, then each of these OUTFIL groups gets the records that were discarded from all other OUTFIL groups that do not have SAVE. The OUTFIL INCLUDE/OMIT parameter is mutually exclusive with the SAVE parameter. Only one of these parameters can be specified for an OUTFIL group.

Note: Note that if the SORTOUT data set has not been associated with any OUTFIL control statement but is present in the JCL, the SORTOUT data set will receive a copy of all records prior to OUTFIL processing. This does not affect the SAVE operation, since SAVE is only pertinent to other OUTFIL group specifications.

Syntax – SAVE

SORT FILEDS=(Starting position, length, data-format, A/D)
OUTFIL FNAMES=DD1, INCLUDE/OMIT COND=(….)
OUTFIL FNAMES=DD2, INCLUDE/OMIT COND=(….)
….......
OUTFIL FNAMES=DDn, SAVE

DDn - Actual DD Name present in JCL.
INCLUDE/OMIT - Specifies the INCLUDE/OMIT condition for specific OUTFIL.
SAVE - Specifies the records not selected for any OUTFIL will be saved to DDn.

Example with INCLUDE and SAVE

Scenario: Input contains the Employee Number, Name, Month & Subject. We want to write the records for the English, Physics & Business subjects to separate datasets then rest all discarded records to another dataset.

EMP NO (1:10)NAME (11:20)MONTH (31:3)SUBJECT (35:10)
1CHERYLJANUARYENGLISH
2NORMANMARCHBUSINESS
3LEONAIDDECEMBERCOMPUTER
4IANOCTOBERHISTORY
5LINDAFEBRURARYPHYSICS
6LITTLEAPRILENGLISH
7PIHUJANUARYHISTORY
8VIKASHOCTOBERBUSINESS
9SATVIJANUARYENGLISH
10LEEDECEMBERPHYSICS
SORT FIELDS=(1,45,CH,A)
  OUTFIL FNAMES=ENGLOUT,INCLUDE=(35,10,CH,EQ,C’ENGLISH   ')
  OUTFIL FNAMES=PHYSOUT,INCLUDE=(35,10,CH,EQ,C’PHYSICS   ')
  OUTFIL FNAMES=BUSIOUT,INCLUDE=(35,10,CH,EQ,C’BUSINESS  ')
  OUTFIL FNAMES=RESTOUT,
    INCLUDE=(35,10,CH,NE,C’ENGLISH   ',AND,
             35,10,CH,NE,C’PHYSICS   ',AND,
             35,10,CH,NE,C’BUSINESS  ')

The first OUTFIL statement writes the records for the English subject to the ENGLOUT data set.

EMP NO (1:10)NAME (11:20)MONTH (31:3)SUBJECT (35:10)
1CHERYLJANUARYENGLISH
6LITTLEAPRILENGLISH
9SATVIJANUARYENGLISH

The second OUTFIL statement writes the records for the Physics subject to the PHYSOUT data set.

EMP NO (1:10)NAME (11:20)MONTH (31:3)SUBJECT (35:10)
5LINDAFEBRURARYPHYSICS
10LEEDECEMBERPHYSICS

The second OUTFIL statement writes the records for the Business subject to the BUSIOUT data set.

EMP NO (1:10)NAME (11:20)MONTH (31:3)SUBJECT (35:10)
2NORMANMARCHBUSINESS
8VIKASHOCTOBERBUSINESS

The fourth OUTFIL statement writes the records not used for English, Physics or Business to the RESTOUT data set.

EMP NO (1:10)NAME (11:20)MONTH (31:3)SUBJECT (35:10)
3LEONAIDDECEMBERCOMPUTER
4IANOCTOBERHISTORY
7PIHUJANUARYHISTORY

But when there are more subjects the include statement for RESTOUT will be more complex. To avoid this SAVE parameter can be used.

  SORT FIELDS=(1,45,CH,A)
  OUTFIL FNAMES=ENGLOUT,INCLUDE=(35,10,CH,EQ,C’ENGLISH   ')
  OUTFIL FNAMES=PHYSOUT,INCLUDE=(35,10,CH,EQ,C’PHYSICS   ')
  OUTFIL FNAMES=BUSIOUT,INCLUDE=(35,10,CH,EQ,C’BUSINESS  ')
  OUTFIL FNAMES=RESTOUT,SAVE
  1. SORT FIELDS=(1,45,CH,A) – sort all outputs in ascending order based on the CH value from 1 to 45 positions.
  2. OUTFIL FNAMES=ENGLOUT,INCLUDE=(35,10,CH,EQ,C’ENGLISH   ‘)– All the records marching with “ENGLISH” from the 35th position of length 10 will be copied to ENGLOUT file.
  3. OUTFIL FNAMES=PHYSOUT,INCLUDE=(35,10,CH,EQ,C’PHYSICS  ‘)All the records marching with “PHYSICS” from the 35th position of length 10 will be copied to PHYSOUT file.
  4. OUTFIL FNAMES=BUSIOUT,INCLUDE=(35,10,CH,EQ,C’BUSINESS  ‘)– All the records marching with “BUSINESS” from the 35th position of length 10 will be copied to BUSIOUT file.
  5. OUTFIL FNAMES=RESTOUT,SAVEAll the records which are ignored from the above three filters will be copied to RESTOUT file. i.e. All COMPUTER, HISTORY records will be copied to RESTOUT file.

The output of this will be the same as above. RESTOUT dataset will contain the same information as in the previous result i.e. rows with the subject in Computer and History.

EMP NO (1:10)NAME (11:20)MONTH (31:3)SUBJECT (35:10)
3LEONAIDDECEMBERCOMPUTER
4IANOCTOBERHISTORY
7PIHUJANUARYHISTORY
  SORT FIELDS=(1,45,CH,A)
  OUTFIL FNAMES=ENGLOUT,INCLUDE=(35,10,CH,EQ,C’ENGLISH   ')
  OUTFIL FNAMES=PHYSOUT,INCLUDE=(35,10,CH,EQ,C’PHYSICS   ')
  OUTFIL FNAMES=BUSIOUT,OMIT=(35,10,CH,EQ,C’BUSINESS  ')
  OUTFIL FNAMES=RESTOUT,SAVE

Now with OMIT condition for the BUSIOUT file all the records which don’t have the subject as BUSINESS. So the RESTOUT fil will now contain only the records having the subject as BUSINESS.

EMP NO (1:10)NAME (11:20)MONTH (31:3)SUBJECT (35:10)
2NORMANMARCHBUSINESS
8VIKASHOCTOBERBUSINESS

JCL blogs – Click Here SYNCSORT Manual: Click Here

Admin

Share
Published by
Admin

Recent Posts

Increase Transparency and Collaboration Product Backlog

A well-maintained product backlog is crucial for successful product development. It serves as a single…

2 months ago

Product Backlog – Incremental value to the customer

Incremental value to the customer refers to the gradual delivery of small, functional parts of…

2 months ago

Product Market, Customer’s Desire, Need, and Challenges

A Product Market refers to the group of potential customers who might be interested in…

2 months ago

PAL-EBM Professional Agile Leadership – EBM Certification

The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…

5 months ago

PAL I Professional Agile Leadership Certification

The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…

5 months ago

Scrum Master Certification: CSM, PSM, SSM

Choosing the right Scrum Master Certification depends on your current experience and career goals. If…

7 months ago