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
What's JCL? |
Sample JCL |
Ready to take the Quiz?
Let's get started with the actual challenge..
π‘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 π.