Friday, November 19, 2021

IBM Z Xplore - Getting through JCL1 Challenge in Fundamentals level

Hello, 

In this blog post, let's take a look at JCL1 challenge in Fundamentals level of IBM Z Xplore. 


Before diving into it - For those who are new here, this is a part of series of posts that I'm doing to cover the challenges in IBM Z Xplore. Click πŸ‘‰ here for the very first post. 

Intro

This challenge will let you get to know about the Job Control Language (very famous in the Mainframe world with the shorthand, JCL), though it isn't a programming language. Imagine JCL as something with which you'll get the work done in IBM z/OS. 

After you click on the JCL1 challenge's tile, you'll be presented with a page which walks you through a brilliant example (at the bottom) to understand JCL's better, so don't miss it. 

What's JCL?

The next page walks you through a sample JCL which (evidently) takes 2 inputs (FNAMES and LNAMES) and produce an output (COMBINED). 
Sample JCL

There is a program (PGM=CBL0001) which process the inputs and creates output. It's written in COBOL. More about COBOL - later! 

Once the JCL's are written, you must submit it (using SUBMIT command) so that it creates a job and get your work done in the background. This job is managed by something called as JES (Job Entry Subsystem). JES is responsible for receiving the jobs into the operating system,  scheduling them for processing by z/OS and controlling their output processing. 

Ready to take the Quiz?

Hit on the "Ready to take the Quiz?" button and you'll be shown with 3 questions on the next page. 

The questions are as follows:

1. What elements might you find in JCL?
2. When JCL gets submitted, it creates a _____ ? (The answer is same as what you (eventually) get after graduating from college? πŸ˜€)
3. In the screenshot example we showed earlier, what is the name of the program the JCL is seeking to run?

As usual, you will (shouldπŸ˜‰) get 3 brownie points if you answer the questions correctly. 

Let's get started with the actual challenge..

Grab a copy of JCL1 Challenge PDF. The only requirement before you begin this challenge is the completion of Files challenge as the knowledge that you grasped about Data Sets and Members are essential for this challenge. 

Steps 1 thru 3 - You'll have to locate a member named JCL1 in ZXP.PUBLIC.JCL PDS, submit it and find the job that you submitted, in the JOBS section of Zowe Explorer extension. 

πŸ’‘Whenever you submit a job in VS Code, there is a message shown on the right side bottom of the screen, containing the Job ID. Clicking on the Job ID will (also) take you to the job's output. 

The job that you submitted simply allocate some datasets which are to be used in this, and other challenges. Notice the CC 0000 next to the job's name? Well, that's condition code (CC) of the job that you submitted and a zero means everything ran as expected. If it's some other number (greater than 4), then the job didn't run as expected and it's something which you should be looking at. 

In exams, you're fail πŸ‘Ž if you get zero marks. In z/OS, you're good if you get zero as the return code out of a job. 


I loved this example πŸ‘‡ that was quoted in the left side bottom of the second page in the challenge PDF.

Think of JCL as the order that a waiter writes up, and JES as the kitchen staff that looks at the order and decides how they’re going to handle it. The L in JCL stands for Language, but it really isn’t a programming language as much as it is a way for us to effectively describe tasks to the system.


Steps 6 thru 8 is all about using a JCL (JCL2 from ZXP.PUBLIC.JCL) to compile a code written in COBOL and then run some code. JCL is just acting as a medium to get the work done. work being the list of statements (aka code or program) written using COBOL. 

COBOL is a programming language used in many financial, healthcare, and government institutions. Its high degree of mathematical precision and straightforward coding methods make it a natural fit when programs need to be fast, accurate, and easy to understand.
            - Quoted from the Challenge PDF. 


In step 6, Copy JCL2 from ZXP.PUBLIC.JCL PDS to your own ZXXXXX.JCL PDS (Please replace ZXXXXX with your Z ID). 

JCL2 and the COBOL program explained

This JCL consists of 2 steps. Lines 3 thru 5 comprises of the first step, which compiles the code written in COBOL. Compiling is a process of converting the code written in human understandable form to Machine Code that is understood by z/OS. Compiling results in an output which is called as Load Module

In JCL, statements that define where data is coming from or going to are known as Data Definition Statements, or simply, DD Statements. Lines 4 and 5 are the datasets containing the source code written in human understandable form and the load module that will hold the Machine code.  

One more thing to note. During compilation, the program that you wrote will also be validated for any rule violations. Only error-free programs are compiled and turned into Machine code. 

Lines 9 thru 16 in the JCL comprises of second step, which executes the program that was compiled in the previous step. 

What the COBOL program does?

The COBOL program reads 2 input files consisting of First names and last names respectively; it writes onto an output file, the combined name (First name + last name). 

We should be letting the COBOL program know where to look for these input file(s) to read data from and the output file where to write the data to. We do this with the help of the Data Definition statements in the lines 11 thru 13, in the JCL.  Below, I've highlighted the lines in the JCL with a yellow rectangle box. 


Note the word after // in all the 3 lines. These are DD (Data Definition) names. The Data Definition statements (or DD statements) which define where data is coming from or going to, will have user defined DD names. We'll have references to these names in the COBOL program that we wrote so that we can establish a link between the data in these data sets and the program. 

Below, I've highlighted the statements in the COBOL program that refers to the DD names in the JCL πŸ‘‡


For example, FIRST-NAME is assigned to FNAMES DD statement in the JCL and FIRST-NAME is what we reference in the COBOL code to read data present in the Data Set associated with FNAMES DD statement. 

Let's go back to the Challenge Instructions PDF. In Step 8, you have to submit JCL2 from ZXXXXX.JCL PDS. After submitting the JCL, you have to head to the output of the job. This time, you'll notice that the job didn't complete with Completion Code 0000. Instead, we got an ABEND (shorthand name for Abnormal End). 

Something is not right and your task is to fix it. 

Hint🧩: Carefully observe the DD statements in the JCL (lines 11 thru 13) and SELECT statements in the COBOL program (lines 11 thru 13). I've added the snapshots of these lines with yellow rectangle boxes aboveπŸ‘†. The COBOL program resides in a PDS (ZXP.PUBLIC.SOURCE) for which you don't have edit access. You can only edit JCL2 residing in ZXXXXX.JCL PDS. Therefore, the DD names at the end of the SELECT statements in the COBOL program should match the DD names in the JCL.  

After fixing it, re-submit the JCL. This time, the job should've completed fine with Completion Code as 0000.

Hang on. You're not done yet!

Before marking this challenge as complete, you must do another task. 

Copy JCL3 from ZXP.PUBLIC.JCL to ZXXXXX.JCL. Take a look inside JCL3 for it contains 13 steps (Tip: Each step in this JCL starts with an EXEC statement). All these steps run a same program which is called as IEBGENER. IEBGENER is a utility program and one of its many uses is to copy data from one data set to another. 

Out of these 13 steps, only one output file is being created and it's ZXXXXX.JCL3OUT. In the first step, the output file is being created and in the other steps, data is appended (data added to the end of the data set) to the output data set. All this is possible with the help of DISP parameter. DISPosition parameters are used to describe how JCL should use or create a data set, and what to do with it after the job completes. Refer steps 12 and 13 in the challenge instruction PDF for more info.

Your job is to submit the JCL as it is (for the first time) and to check the output data set, ZXXXXX.JCL3OUT. You should not have any repeat stops in the output data set. If something is listed twice, you should go back to the JCL and edit it.

Here is a glimpse of the output data set, ZXXXXX.JCL3OUT after submitting JCL3 as it is πŸ‘‡. 


If you go through the list of stops (lines 5 thru 16), you'll notice that couple of stops are repeated (lines 8 and 13). Now, we have to re-submit the JCL after ensuring that these stops aren't repeated. While you're on it, just keep in mind that what you're going to remove in the JCL can be just a line (the line number adds up to 6 πŸ˜‰) or an entire step. Don't leave an empty line on the JCL. When you are done with the edits in the JCL, locate and delete the output dataset ZXXXXX.JCL3OUT before re-submitting the JCL.

Here is the output dataset after fix πŸ‘‡. 


The End

Submit your work by submitting CHKJCL in ZXP.PUBLIC.JCL. Go back to IBM Z Xplore learning platform -> Fundamentals level -> JCL1 challenge tile -> Scroll to the bottom and hit on Check JCL submission button. Hope you successfully completed the challenge. 

Next one is USS, so keep a tab on this blog for I'll soon add a post covering the next challenge.  Thanks for reading!