JCL Tutorials: Features and Practical Examples
Welcome to our JCL (Job Control Language) programming tutorial portal! Here at cobolcoder.com, we are dedicated to providing you with detailed and accessible resources to help you master JCL and optimize your workflows in mainframe environments.
What is JCL? Job Control Language (JCL) is essential in the world of mainframes, as it allows the definition and management of task and program execution in operating systems like IBM z/OS. On our platform, you will find a series of step-by-step tutorials designed to help you understand the fundamentals of JCL, from job creation to resource management and performance optimization.
Dive into the fascinating world of JCL with us! Explore our tutorials, participate in the community, and take your mainframe programming skills to the next level. We are excited to be a part of your JCL learning journey!
Basic Guides to Programming in JCL
SORT in JCL
In JCL (Job Control Language), you can use the SORT program to sort two files.
//SORTJOB JOB (123),'Nombre del job',CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1)
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=A
//SORTIN1 DD DSN=your.input.file1,DISP=SHR
//SORTIN2 DD DSN=your.input.file2,DISP=SHR
//SORTOUT DD DSN=your.output.file,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(5,5),RLSE)
//SYSIN DD * SORT FIELDS=(start_position,length,format,A/D) /*
This article explains its main features with programming examples.
SUM FIELDS
The SUM FIELDS JCL statement indicates that when two records have equal control fields in a SORT or merge operation, the summary fields are summed, the sum is placed in one of the records, and the other is deleted. If the EQUALS option is activated, the first record is retained; if the NOEQUALS option is activated, the retained record is unpredictable.
//SORTJOB JOB ...
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=input.dataset,DISP=SHR
//SORTOUT DD DSN=output.dataset,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(5,5)),DCB=(RECFM=FB,LRECL=80)
//SYSIN DD *
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(10,3,ZD),FORMAT=BI
/*
The following entry details and explains its main features with examples and illustrations.
INCLUDE Condition – SORT in JCL
In JCL (Job Control Language), the INCLUDE condition is used in the context of the SORT step to specify a set of records that should be included in the output of the sorting step. The INCLUDE clause helps filter records based on specific criteria, retaining only those that meet the condition. Here’s a basic layout and explanation of the INCLUDE condition’s features:
//SORTJOB JOB (123),'Sort with INCLUDE',CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1)
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=A
//SORTIN DD DSN=your.input.file,DISP=SHR
//SORTOUT DD DSN=your.output.file,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(5,5),RLSE)
//SYSIN DD *
SORT FIELDS=(1,10,A)
INCLUDE COND=(11,2,CH,EQ,C'20')
/*
In this example, the INCLUDE
condition is used to include only the records that meet the specified condition. In this case, records where the content in positions 11 and 12 is equal to ’20’.
OUTFIL in JCL: SORT to Divide a File
The OUTFIL
in JCL is used with the SORT
utility to create multiple output files from a single input file, based on specific criteria. This process is highly useful when we want to divide records in a file according to a certain condition, such as status, type, or any other identifying field. In this example, we’ll cover how to use OUTFIL
in JCL
SORT
to split a file based on a particular position and value.
Below is a JCL example using SORT
to divide USER.FILE.ALL
into two files: USER.FILE.STUDENTS
for students and USER.FILE.TEACHERS
for teachers.
//SPLITFILE JOB (ACCT),'Divide Files',CLASS=A,MSGCLASS=X
//STEP1 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SORTIN DD DSN=USER.FILE.ALL,DISP=SHR
//STUDENTS DD DSN=USER.FILE.STUDENTS,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(5,5),RLSE),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//TEACHERS DD DSN=USER.FILE.TEACHERS,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(5,5),RLSE),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=STUDENTS,INCLUDE=(26,8,CH,EQ,C'STUDENT')
OUTFIL FNAMES=TEACHERS,INCLUDE=(26,8,CH,EQ,C'TEACHER')
/*
After running this JCL, USER.FILE.STUDENTS
will contain records with “STUDENT” in the specified position, and USER.FILE.TEACHERS
will contain records with “TEACHER” in that same position.
This page provides a comprehensive introduction to JCL (Job Control Language), covering essential features, practical examples, and key functionality used in mainframe environments. By exploring concepts like job structure, data handling, and common utilities, readers gain practical knowledge to effectively manage batch processing tasks. With detailed examples, this guide equips beginners and experienced users alike with the tools to optimize JCL for real-world scenarios.