Job Control Language, JCL
Part Two - Challenge #05

As a System Programmer, you prepare the environments and infrastructure needed by developers, operators, security administrators, database administrators, and other IT functions to do their jobs. If there are new requirements or growing applications– perhaps your company is expanding into a new region or has a new product - you have to create and manage those systems.

You also have the ability to make the environment easier for developers to use so they don’t have to code everything into each program. For example, if the data records in the system are in a certain order (aka sorted) the developer’s application will run faster and the application developers will not need to write extra code in their programs.

This challenge will introduce you to the commands and language used to run pre-defined programs or jobs and perform tasks on the system.

Background:

For every job that you submit, you need to tell z/OS where to find the appropriate input, how to process that input, and what to do with the resulting output. You use job control language (JCL) to convey this information to z/OS through a set of statements known as job control statements.

While application programmers need some knowledge of JCL, the production control analyst or system programmers must be highly proficient with JCL, to create, monitor, correct and rerun the company's daily batch workload.

You will learn about the input/output relationship between program execution and JCL

Understanding JCL is required to be considered experienced with z/OS. Many employers are looking for JCL experience.

In previous challenges you submitted JCL for execution and viewed the output using SDSF.

In challenge #05 you will learn the basics of JCL.


Focusing on the purpose of JCL can make JCL easy to learn.
Purpose of JCL:
  • Identify what program to execute
  • Identify program inputs and outputs
Program Execution
  • A program has internally coded file names.
  • A program reads, writes, and updates those internally coded file names.
  • Program execution requires an internally coded file name to be redirected to a z/OS managed physical resource.
    ---------------------------------------------------------------
    The z/OS managed physical resources include:
      1) Data Set Names
      2) Unix File Names
      3) Any physical input/output device defined to z/OS
    ----------------------------------------------------------------
  • How is a program internal file name redirected to a z/OS managed resource?
    -- The best answer is JCL, Job Control Language
    -- Other answers could include TSO ALLOCATE command
      and a system supervisor call, (SVC 99), aka DYNALLOC
JCL Syntax
  • // starting in column 1
  • JCL is UPPERCASE
      Only exception is lowercase in quotes for unix file names, unix parameters, etc.
  • The 2 most important JCL operations are:
    EXEC
       - used to identify what program to execute
    DD
       - used to connect program file names with z/OS managed inputs and outputs

JCL DD, Data Definition, operation is used to redirect a program internally coded file name with a z/OS defined physical data source.

JCL below has JCL DD operations with ddnames spelled exactly as the internally coded file names within the executed sort program.

Program SORT is coded with internal file names to -
Open and read from:
    SORTIN
    SYSIN
Open and write to:
    SORTOUT
    SYSOUT

What is a JCL ddname?

  • A ddname is a label on the DD operation
      where DD is a JCL reserved word, Data Definition
  • A program requests access to inputs and outputs using file names
  • A program file name needs a ddname
      where the file name = ddname
  • DD parameters describe the input/output data source to be accessed by the program

What is a JCL step?

  • Each EXEC operation starts a new step
  • A step includes an EXEC operation followed by DD operations
  • A stepname is coded immediately after // on the EXEC operation
  • A subsequent EXEC operation is the end of the previous step and start of a new step

Description of a few DD parameters describing the data input/output resources

  • DSN=value - where value is a data set name
  • DISP=value - where value is data set name disposition,
    such as NEW, OLD, SHR, CATLG
  • PATH=value - where value is a unix file name - in quotes if mixed or lower case
  • PATHOPTS=, PATHMODE=, and PATHDISP= where values assign unix file name dispositions and attributes
  • SYSOUT=* - write to system managed output area known as the JES Spool
      where JES Spool is a special formatted area on disk,
      SDSF is used to view the JES Spool

----------------------------------------------------------------------------------------------
The program determines JCL the ddname.
----------------------------------------------------------------------------------------------
If a program file name does not have an associated JCL ddname, then the program execution will fail
with a message reporting no associated ddname was found for the program file name.


A short video lecture on JCL (Optional)

Less than 13 minutes -


Challenge:

What you are expected to understand for future challenges

Challenge 5 is the last challenge with step by step actions accompanied by screen shots on how to navigate ISPF, ISPF Editor, and SDSF.

Assumption is made in future challenges that you understand how to:

  • Use ISPF 3.4 panel or DSLIST command to list data set names
  • Use ISPF Editor to modify data set names and/or data set member names
        Remember ISPF Editor Command Summary in References drop down
        and pressing F1 for online ISPF Editor help tutorial
  • Use SDSF to locate and view your JCL job output

If you struggle with the increasingly abbreviated instructions related to
ISPF, ISPF Editor, and SDSF, then review previous challenges such as this challenge.


JCL in Action

While the challenge involves JCL execution of a program to process a small number of data records, millions of data records are processed in large enterprises using JCL.

Actions:

  1. From the ISPF command or ISPF option line enter tso submit 'zos.public.jcl(sortpgm)'
      See Figure #1 and Figure #2 below
  2. From the ISPF command or option line enter =sd;st to jump to the SDSF status panel.
      See Figure #3 below
      Enter prefix ; owner z##### to see status of all jobs your id owns.
  3. You should find job SORTPGM output.
      See Figure #4 below
  4. Tab to left of SORTPGM JCL job output.
      See Figure #4 below
  5. Enter ? question mark to left of SORTPGM to see DDNAME sections of the JCL job output.
      See Figure #4 below
    *NOTE: JESMSGLG, JESJCL, and JESYSMSG are system generated DDNAMEs
       as a result of JCL execution.
    SORTOUT, and SYSOUT DDNAMEs are written as a result of SORTPGM execution.
  6. Use tab key typing s to left of each DDNAME section to select the individual DDNAME sections to be viewed.
      See Figure #5
      The result of enter is a select of the first DDNAME to be viewed.
      Press F3 results in a select of the next DDNAME to be viewed.
      Continue pressing F3 to view each JCL JOB DDNAME output section.
  7. JESMSGLG is a dynamically allocated DDNAME section containing system messages for this job.
      See Figure #6
      Observe 00 in the Return Code RC column indicating success.
      Observe line with 6 CARDS READ which means 6 JCL statements were processed.
  8. JESJCL is a dynamically allocated DDNAME section containing all JCL statements and JES2 control statements.
      See Figure #7
      Observe each JCL statement is numbered.
      Observe SORTIN is redirected to data set name ZOS.MTM2019.PUBLIC.SHARED.DATA member name AIRCODES.
      Observe SORTIN DD parameter DISP=SHR.
        SHR means the data set name should exist and can be shared with other jobs.
      Observe SYSIN is redirected to data set name ZOS.MTM2019.PUBLIC.SHARED.DATA member name SORTCMD.
      Observe SYSIN DD parameter DISP=SHR.
        SHR means the data set name should exist and can be shared with other jobs.
      Observe SORTOUT is redirected to SYSOUT=*, the JES spool output area visible using SDSF.
      Observe SYSOUT is redirected to SYSOUT=*, the JES spool output area visible using SDSF.
  9. JESYSMSG is a dynamically allocated DDNAME section.
      See Figure #8
      JESYSMSG includes:
        Job's hardcopy log
        JES2 and operator messages about the job processing
        Allocation of devices and volumes
        Execution and termination of the job steps and the job
        Disposition of data sets
  10. SORTOUT is the where program SORT wrote the results of the sort operation.
      See Figure #9
      SORT operation included:
        Data to be sorted from //SORTIN DD DSN=ZOS.MTM2019.PUBLIC.SHARED.DATA(AIRCODES)
        Sort operational command from //SYSIN DD DSN=ZOS.MTM2019.PUBLIC.SHARED.DATA(SORTCMD)
  11. SYSOUT is where program SORT wrote messages about the sort operation.
      See Figure #10
      Observe SORT FIELDS=(1,3,AC,D)
        Above sort command was read from //SYSIN DD DSN=ZOS.MTM2019.PUBLIC.SHARED.DATA(SORTCMD)
        Sort fields beginning in column 1 for a length of 3 using ASCII character format (AC) in descending order (D).

Figure #1


Figure #2


Figure #3


Figure #4


Figure #5


Figure #6


Figure #7


Figure #8


Figure #9


Figure #10


Modify a sort command and submit JCL to execute a SORT program that reads your modified sort command
  1. Use ISPF dslist, the data set list command, to list your pds.data partitioned data set.
      See Figure #11
  2. Tab to the left of your pds.data partitioned data set and enter e to edit.
      See Figure #12
  3. Enter s sortcity to select partitioned data set member name sortcity
      See Figure #13
  4. Member sortcity is empty because it is a new member.
      See Figure #14
      Enter copy 'zos.mtm2019.public.shared.data(sortcity)' to copy data into the new member
  5. Member sortcity now includes a sort control statement.
      See Figure #15
      Enter reset to suppress the ==MSG> lines.
    Description of SORT FIELDS=values:
    SORT FIELDS=(starting position, length, data format, A/D)
      where A/D is Ascending or Descending order
    Change starting position to 30, length to 9, and sort order to Descending.
      No screen available showing the change
    Press F3 to save, end, and exit ISPF edit mode
  6. Use ISPF dslist, the data set list command, to list your jcl partitioned data set.
      See Figure #16
  7. Tab to the left of your jcl partitioned data set name and enter e to edit.
      See Figure #17
  8. Enter s sortcity to select partitioned data set member name sortcity
      See Figure #18
  9. Member sortcity is empty because it is a new member.
      See Figure #19
      Enter copy 'zos.public.jcl(sortcity)' to copy JCL into the new member
  10. Member sortcity now includes JCL
      See Figure #20
    JCL Description:
        Line 1 is a JCL JOB operation has SORTCITY as a given name
        Line 2 is a JCL EXEC operation to execute program SORT
        Line 3 is a JCL DD operation to read data from SORTIN
          where member name is CITIES and partitioned data set name is ZOS.MTM2019.PUBLIC.SHARED.DATA
        Line 4 is a JCL DD operation to read sort control command from SYSIN
          where member name is SORTCITY and partitioned data set name is your ID PDS.DATA
          You previously changed the sort control command in the SYSIN
          &SYSUID. will be replaced with your ID
          Member name SORTCITY in your PDS.DATA partitioned data set has your change
        Line 5 is a JCL DD operation to write sorted data to SORTOUT
          where SYSOUT=* means the output will be in the JES spool
        Line 6 is a JCL DD operation to write program sort messages to SYSOUT
          where SYSOUT=* means the output will be in the JES spool
      Enter submit ; =sd ; st
        JCL job is submitted to the system for processing
        Jump to SDSF
        Status jobs using SDSF
  11. A message reading JOB SORTCITY(JOB#####) SUBMITTED
      See Figure #21
  12. Review SORTCITY JOB output
      See Figure #22
      Tab to left of SORTCITY, enter ?
  13. Review each DDNAME section of SORTCITY output
      See Figure #23
      Tab to left of each DDNAME section, type s to select each section, then enter
  14. JESMSGLG is first DDNAME section
      See Figure #24
      Observe return code RC is 00 indicating successful completion.
      Press F3 to leave JESMSGLG
  15. JESJCL is second DDNAME section
      See Figure #25
      Observe the substitution for &SYSUID..
      Press F3 to leave JESJCL
  16. JESYSMSG is third DDNAME section
      See Figure #26
      Observe the system allocated data set names.
      Press F3 to leave JESYSMSG
  17. SYSOUT is forth DDNAME section
      See Figure #27
      Observe program sort messages.
      The output shows the SORT FIELDS= values you should have coded.
      Press F3 to return to SDSF status panel
  18. Use ISPF dslist, the data set list command, to list your P2.OUTPUT partitioned data set.
      See Figure #28
  19. Tab to the left of your P2.OUTPUT partitioned data set and enter b to browse.
      See Figure #29
  20. Tab to the left of member name #05 and enter s to select the member to be browsed.
      See Figure #30
  21. The data sorted is displayed.
      See Figure #31
      Enter cols to display columns
  22. The data sorted is displayed with column header visible
      See Figure #32
      Observe column 30 for a length of 9.
      The data was sorted in descending order displaying the largest city by population in the world.
      If the data appears as shown, you successfully complete challenge 5.

Figure #11

Figure #12

Figure #13

Figure #14

Figure #15

Figure #16

Figure #17

Figure #18

Figure #19

Figure #20

Figure #21

Figure #22

Figure #23

Figure #24

Figure #25

Figure #26

Figure #27

Figure #28

Figure #29

Figure #30

Figure #31

Figure #32


The challenge created member #05 in data set name P2.OUTPUT from SORT program output.

Before moving on to the next challenge, re-read "What you are expected to understand for future challenges".

Congratulations! You are done with challenge #05 and you ready for the next challenge.

Interesting fact...

To better understand JCL, understand why it exists. It’s all about the I/O – how fast can we make the input/output so we can process billions of records (think credit card transactions coming in from all over the world at the same time). To do that, the system needs to have the fastest independent input output devices. The DD statement makes this possible. It associates an internal program file name with a physical resource which allows I/O device independence. Programs do not have to be recompiled to go after different data sources and they retain stability. This is why some programs still running today have been around for 20+ years and still keep on going.


Next: Challenge #06