Conditional JCL
COND Keyword or IF Constructs
  Table of Contents  v-14.03.28 - jclcon01.htm 
  Introduction
  JCL using COND Parameter
  JCL using IF Construct
  The Mainline COBOL Program
  Summary
  Software Agreement and Disclaimer
  Downloads and Links
  Current Server or Internet Access
  Internet Access Required
  Glossary of Terms
  Comments or Feedback
  Company Overview
The SimoTime Home Page

Table of Contents Previous Section Next Section Introduction

This suite of programs provides an example of how mainframe JCL can do conditional processing and parameter passing. The first JCL example will focus on the approaches used by JES/2 using the "COND=" parameter on the JOB or EXEC statement. With JES/3 the conditional processing was improved to use "IF" statements. The second JCL example will focus on the IF, THEN, ELSE and ENDIF statement constructs. Both JCL examples accomplished the same task. However, the second JCL example has additional information displayed when there is a difference between the actual and expected return code.

The use of the COND parameter can be very difficult to code and understand. I would recommend the use of the IF, THEN, ELSE and ENDIF statement construct if you have a choice.

Both JCL examples will use a single COBOL program to process the parameter string provided by the JCL members. The COBOL program will also set various return codes prior to returning control back to JCL

The COBOL program is written using COBOL/2 dialect but also works with COBOL for MVS and COBOL/370. This suite of programs may serve as a tutorial for programmers that are new to COBOL and mainframe JCL and as a reference for experienced programmers. Two JCL members are provided to run the jobs as an MVS batch jobs on an IBM mainframe orin a distributed environment (Linux, Unix or Windows) using Micro Focus.

Refer to http://www.microfocus.com for additional information.


We have made a significant effort to ensure the documents and software technologies are correct and accurate. We reserve the right to make changes without notice at any time. The function delivered in this version is based upon the enhancement requests from a specific group of users. The intent is to provide changes as the need arises and in a timeframe that is dependent upon the availability of resources.

Copyright © 1987-2015
SimoTime Technologies
All Rights Reserved

Table of Contents Previous Section Next Section JCL using COND Parameter

The following is the mainframe JCL (JCLCONJ1.jcl) example that uses the COND parameter. The first step (NOPARM) will always execute and since there is no parameter specified the COBOL program (JCLCONC1.CBL) will simply set the return code to zero (0) and return to the JCL member.

The second step (COND00A) will always execute the COBOL program passing a parameter that will cause the COBOL program to set a Return-Code of zero (0). The third step (COND00B) will execute only if the return code from all the previous steps is zero (0). The JCL will then continue to execute testing various conditions as documented in the JCL member. The JOB statement will need to be modified for specific mainframe environments.

//JCLCONJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//JOBLIB   DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//* *******************************************************************
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2015 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Process a parameter string passed from the JCL
//* Author - SimoTime Technologies
//* Date   - January 24, 1996
//*
//* This is a sample program that shows how a COBOL program can
//* process input from the JCL using the PARM keyword from the EXEC
//* statement.
//*
//* The COBOL program will set a condition and JCL will procees
//* accordingly.
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express
//*
//STARTING EXEC PGM=JCLCONC1,PARM='STARTING job JCLCONJ1.JCL...'
//*
//* *******************************************************************
//* Execute the COBOL program without a parameter.
//*
//NOPARM   EXEC PGM=JCLCONC1
//*
//* *******************************************************************
//* Execute the COBOL program with a parameter.
//* Based on the PARM='parameter' the COBOL program will set the Return
//* code to 0.
//*
//COND00A  EXEC PGM=JCLCONC1,PARM='MSG-00 --- This is message zero...'
//*
//COND00B  EXEC PGM=JCLCONC1,COND=(0,LT),PARM='Return Code = 00...'
//*
//* This step (COND00B) will be bypassed if the Return Code
//* of any of the preceding job steps is not zero (0).
//*
//* *******************************************************************
//* Execute the COBOL program with a parameter.
//* Based on the PARM='parameter' the COBOL program will set the Return
//* code to 4.
//*
//COND04A  EXEC PGM=JCLCONC1,PARM='MSG-04 -- This is message four...'
//*
//COND04B  EXEC PGM=JCLCONC1,COND=(4,NE,COND04A),
//             PARM='Return Code is equal to 04...'
//*
//* This step (COND04B) will be bypassed if COND=4 is not
//* equal to the Return Code of the preceding job step (COND04A).
//*
//* *******************************************************************
//* Execute the COBOL program with a parameter.
//* Based on the PARM='parameter' the COBOL program will set the Return
//* code to 8.
//*
//COND08A  EXEC PGM=JCLCONC1,PARM='MSG-08 -- This is message eight...'
//*
//COND08B  EXEC PGM=JCLCONC1,COND=(8,LT,COND08A),
//             PARM='Return Code is equal to or greater than 08...'
//*
//* This step (COND08B) will be bypassed if COND=8 is less
//* than or equal to the Return Code of the preceding job step
//* (COND08A).
//*
//* *******************************************************************
//* Execute the COBOL program with a parameter.
//*
//EOJTEST1 EXEC PGM=JCLCONC1,COND=(1,GE),
//             PARM='All Job Steps had a zero Return Code...'
//*
//* The preceding step (EOJTEST1) should be bypassed.
//*
//EOJTEST2 EXEC PGM=JCLCONC1,COND=(8,LT),
//             PARM='All Job Steps had a Return Code of 0 through 8...'
//*
//* This step (EOJTEST2) should execute.
//* If 8 is LESS THAN the return code from any of the previous steps
//* then do not execute this step.
//*
//EOJTEST3 EXEC PGM=JCLCONC1,COND=(9,GE),
//             PARM='Return Code greater than 8 for a job step.'
//*
//* This step (EOJTEST3) should be bypassed.
//*
//FINISHED EXEC PGM=JCLCONC1,PARM='FINISHED job JCLCONJ1.JCL...'
//*
//*

Table of Contents Previous Section Next Section JCL using IF Construct

The following is the mainframe JCL (JCLCONJ2.jcl) example that uses the IF, THEN, ELSE and ENDIF statement construct. The first step (NOPARM) will always execute and since there is no parameter specified the COBOL program (JCLCONC1.CBL) will simply set the return code to zero (0) and return to the JCL member.

The second step (COND00A) will always execute the COBOL program passing a parameter that will cause the COBOL program to set a Return-Code of zero (0). The third step (COND00B) will execute only if the return code from all the previous steps is zero (0). The JCL will then continue to execute testing various conditions as documented in the JCL member. The JOB statement will need to be modified for specific mainframe environments

//JCLCONJ2 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//JOBLIB   DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//* *******************************************************************
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2015 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Process a parameter string passed from the JCL
//* Author - SimoTime Technologies
//* Date   - January 24, 1996
//*
//* This is a sample program that shows how a COBOL program can
//* process input from the JCL using the PARM keyword from the EXEC
//* statement.
//*
//* The COBOL program will set a condition and JCL will procees
//* accordingly.
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express
//*
//* *******************************************************************
//* Execute the COBOL program without a parameter.
//*
//NOPARM   EXEC PGM=JCLCONC1
//*
//* *******************************************************************
//* Execute the COBOL program with a parameter.
//* Based on the PARM='parameter' the COBOL program will set the Return
//* code to 0.
//*
//COND00A  EXEC PGM=JCLCONC1,PARM='MSG-00 --- This is message zero...'
//*
// IF (RC EQ 0) THEN
//COND00B  EXEC PGM=JCLCONC1,PARM='COND00B - Return Code = 00...'
// ELSE
//COND00C  EXEC PGM=JCLCONC1,PARM='COND00C - Unexpected Return Code...'
// ENDIF
//*
//* The preceding step (COND00B) will be bypassed if CC is not equal
//* to the Return Code (RC=0) of any of the preceding job steps.
//*
//* *******************************************************************
//* Execute the COBOL program with a parameter.
//* Based on the PARM='parameter' the COBOL program will set the Return
//* code to 4.
//*
//COND04A  EXEC PGM=JCLCONC1,PARM='MSG-04 -- This is message four...'
//*
// IF (COND04A.RC EQ 4) THEN
//COND04B  EXEC PGM=JCLCONC1,PARM='COND04C - Return Code = 04...'
// ELSE
//COND04C  EXEC PGM=JCLCONC1,PARM='COND04C - Unexpected Return Code...'
// ENDIF
//*
//* The preceding step (COND04B) will be bypassed if CC is not equal
//* to the Return Code (RC=4) of the preceding job step (COND04A).
//*
//* *******************************************************************
//* Execute the COBOL program with a parameter.
//* Based on the PARM='parameter' the COBOL program will set the Return
//* code to 8.
//*
//COND08A  EXEC PGM=JCLCONC1,PARM='MSG-08 -- This is message eight...'
//*
// IF (COND08A.RC GT 7 AND RC LT 9) THEN
//COND08B  EXEC PGM=JCLCONC1,
//             PARM='COND08C - Return Code is  GT 7 and LT 9...'
// ELSE
//COND08C  EXEC PGM=JCLCONC1,PARM='COND08C - Unexpected Return Code...'
// ENDIF
//*
//* The preceding step (COND08B) will be bypassed if CC is not equal
//* to the Return Code (RC=8) of the preceding job step (COND08A).
//* (COND08A).
//*
//* *******************************************************************
//* Execute the COBOL program with a parameter.
//*
// IF (RC EQ 0) THEN
//EOJTEST1 EXEC PGM=JCLCONC1,
//             PARM='All Job Steps had a zero Return Code...'
// ENDIF
//*
//* The preceding step (EOJTEST1) should be bypassed.
//*
// IF (RC LT 9) THEN
//EOJTEST2 EXEC PGM=JCLCONC1,
//             PARM='All Job Steps had a Return Code of 0 through 8...'
// ENDIF
//*
//* The preceding step (EOJTEST2) should execute.
//*
// IF (RC GT 8) THEN
//EOJTEST3 EXEC PGM=JCLCONC1,COND=(9,GE),
//             PARM='Return Code greater than 8 for a job step.'
// ENDIF
//*
//* The preceding step (EOJTEST3) should be bypassed.
//*

Table of Contents Previous Section Next Section The Mainline COBOL Program

This program (JCLCONC1.cbl) was written to be used as a teaching and learning aid. When a COBOL program is executed from a JCL member a data string (or parameter) may be passed from the JCL member to the COBOL program using the PARM keyword as follows

//JCLCONS2 EXEC PGM=JCLCONC1,PARM='datastring'

When the data string is passed from JCL to COBOL it is preceded with a two-byte binary value that specifies the length of the data string. For example, if the data string is ten characters in length the actual information passed to the COBOL program would be a two-byte binary value of ten or x'000A' followed by the ten character data string. If the COBOL program is executed from JCL without a parameter the two-byte binary value would be zero or x'0000'.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    JCLCONC1.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      * Copyright (C) 1987-2014 SimoTime Enterprises.                 *
      *                                                               *
      * All rights reserved.  Unpublished, all rights reserved under  *
      * copyright law and international treaty.  Use of a copyright   *
      * notice is precautionary only and does not imply publication   *
      * or disclosure.                                                *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any non-commercial purpose and without fee is hereby      *
      * granted, provided the SimoTime copyright notice appear on all *
      * copies of the software. The SimoTime name or Logo may not be  *
      * used in any advertising or publicity pertaining to the use    *
      * of the software without the written permission of SimoTime    *
      * Enterprises.                                                  *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any commercial purpose requires a fee to be paid to       *
      * SimoTime Enterprises. Once the fee is received by SimoTime    *
      * the latest version of the software will be delivered and a    *
      * license will be granted for use within an enterprise,         *
      * provided the SimoTime copyright notice appear on all copies   *
      * of the software. The SimoTime name or Logo may not be used    *
      * in any advertising or publicity pertaining to the use of the  *
      * software without the written permission of SimoTime           *
      * Enterprises.                                                  *
      *                                                               *
      * SimoTime Enterprises makes no warranty or representations     *
      * about the suitability of the software for any purpose. It is  *
      * provided "AS IS" without any expressed or implied warranty,   *
      * including the implied warranties of merchantability, fitness  *
      * for a particular purpose and non-infringement. SimoTime       *
      * Enterprises shall not be liable for any direct, indirect,     *
      * special or consequential damages resulting from the loss of   *
      * use, data or projects, whether in an action of contract or    *
      * tort, arising out of or in connection with the use or         *
      * performance of this software                                  *
      *                                                               *
      * SimoTime Enterprises                                          *
      * 15 Carnoustie Drive                                           *
      * Novato, CA 94949-5849                                         *
      * 415.883.6565                                                  *
      *                                                               *
      * RESTRICTED RIGHTS LEGEND                                      *
      * Use, duplication, or disclosure by the Government is subject  *
      * to restrictions as set forth in subparagraph (c)(1)(ii) of    *
      * the Rights in Technical Data and Computer Software clause at  *
      * DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of          *
      * Commercial  Computer Software - Restricted Rights  at 48      *
      * CFR 52.227-19, as applicable.  Contact SimoTime Enterprises,  *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *****************************************************************
      *      This program is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
      * Source Member: JCLCONC1.CBL
      *****************************************************************
      *
      * JCLCONC1 - This program will process a JCL parameter.
      *
      * CALLING PROTOCOL
      * ----------------
      * USE STANDARD PROCEDURE TO EXECUTE, RUN OR ANIMATE.
      *
      * DESCRIPTION
      * -----------
      * This program will process the JCL parameter from the PARM
      * keyword of the EXEC staement.
      *
      * //     EXEC  PGM=PROGNAME,PARM='text string...'
      *
      * This program will simply display the text string.
      *
      ****************************************************************
      *
      * MAINTENANCE
      * -----------
      * 1997/02/27 Simmons, Created program.
      *
      *****************************************************************
      *
       DATA DIVISION.
       WORKING-STORAGE SECTION.
      *
      *****************************************************************
      *    Data-structure for Title and Copyright...
      *    ------------------------------------------------------------
       01  SIM-TITLE.
           05  T1 pic X(11) value '* JCLCONC1 '.
           05  T2 pic X(34) value 'Conditional JCL with a Parameter  '.
           05  T3 pic X(10) value ' v03.01.24'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* JCLCONC1 '.
           05  C2 pic X(20) value 'Copyright 1987-2014 '.
           05  C3 pic X(28) value '--- SimoTime Enterprises ---'.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* JCLCONC1 '.
           05  C2 pic X(32) value 'Thank you for using this softwar'.
           05  C3 pic X(32) value 'e provided from SimoTime Enterpr'.
           05  C4 pic X(04) value 'ises'.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* JCLCONC1 '.
           05  C2 pic X(32) value 'Please send all inquires or sugg'.
           05  C3 pic X(32) value 'estions to the helpdesk@simotime'.
           05  C4 pic X(04) value '.com'.

       01  FIRST-TIME              pic X       value 'Y'.

       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* JCLCONC1 '.
           05  MESSAGE-TEXT        pic X(68).

       01  MESSAGE-TEXT-01.
           05  filler   pic X(27)  value '***-JCL Parameter length = '.
           05  JCL-PARM-LENGTH     pic 9(5)    value 0.

       01  MESSAGE-TEXT-02.
           05  filler   pic X(8)   value '***-JCL '.
           05  MESSAGE-TEXT-02-JCL pic X(60)   value SPACES.

       01  LOCAL-RETURN-CODE       pic S9(9)   comp    value 0.
       01  WORK-07                 pic X(7)    value SPACES.

      *****************************************************************
       LINKAGE SECTION.
       01  PARM-BUFFER.
           05  PARM-LENGTH         pic S9(4)   comp.
           05  PARM-DATA           pic X(256).

      *****************************************************************
       PROCEDURE DIVISION using PARM-BUFFER.
           if  FIRST-TIME not = 'N'
               perform Z-POST-COPYRIGHT
               move 'N' to FIRST-TIME
           end-if

           subtract LOCAL-RETURN-CODE from LOCAL-RETURN-CODE
           add PARM-LENGTH to ZERO giving JCL-PARM-LENGTH
           move MESSAGE-TEXT-01 to MESSAGE-TEXT
           perform Z-POST-MESSAGE

           if  PARM-LENGTH > 0
               move PARM-DATA(1:PARM-LENGTH) to MESSAGE-TEXT-02-JCL
               move MESSAGE-TEXT-02          to MESSAGE-TEXT
               perform Z-POST-MESSAGE
               perform SET-LOCAL-RETURN-CODE
           end-if

           perform Z-THANK-YOU.

           add LOCAL-RETURN-CODE to ZERO giving RETURN-CODE

           GOBACK.

      *****************************************************************
       SET-LOCAL-RETURN-CODE.
           subtract LOCAL-RETURN-CODE from LOCAL-RETURN-CODE
           if  PARM-LENGTH > 6
               move PARM-DATA(1:7) to WORK-07
               evaluate WORK-07
                 when 'MSG-00 ' move ZERO to LOCAL-RETURN-CODE
                 when 'MSG-04 ' add  4 to ZERO giving LOCAL-RETURN-CODE
                 when 'MSG-08 ' add  8 to ZERO giving LOCAL-RETURN-CODE
                 when 'MSG-12 ' add 12 to ZERO giving LOCAL-RETURN-CODE
                 when 'MSG-16 ' add 16 to ZERO giving LOCAL-RETURN-CODE
               end-evaluate
           end-if
           exit.

      *****************************************************************
      *    Display Copyright or Program Messages...
      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE      upon console
           display SIM-COPYRIGHT  upon console
           exit.

      *****************************************************************
       Z-POST-MESSAGE.
           display MESSAGE-BUFFER upon console
           move SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
       Z-THANK-YOU.
           display SIM-THANKS-01  upon console
           display SIM-THANKS-02  upon console
           exit.
      *****************************************************************
      *      This example is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Table of Contents Previous Section Next Section Summary

The purpose of this document is to assist as a tutorial for new programmers or as a quick reference for experienced programmers. In the world of programming there are many ways to solve a problem. This document and the links to other documents are intended to provide a choice of alternatives.

Table of Contents Previous Section Next Section Software Agreement and Disclaimer

Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Enterprises. Once the fee is received by SimoTime the latest version of the software, documentation or training material will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.

SimoTime Enterprises makes no warranty or representations about the suitability of the software, documentation or learning material for any purpose. It is provided "AS IS" without any expressed or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Enterprises shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software, documentation or training material.

Table of Contents Previous Section Next Section Downloads and Links

This section includes links to documents with additional information that are beyond the scope and purpose of this document. The first group of documents may be available from a local system or via an internet connection, the second group of documents will require an internet connection.

Note:  A SimoTime License is required for the items to be made available on a local system or server.

Table of Contents Previous Section Next Section Current Server or Internet Access

The following links may be to the current server or to the Internet.

Note: The latest versions of the SimoTime Documents and Program Suites are available on the Internet and may be accessed using the Link to Internet icon. If a user has a SimoTime Enterprise License the Documents and Program Suites may be available on a local server and accessed using the Link to Server icon.

Link to Internet   Link to Server   Explore the JCL Connection for more examples of JCL functionality with programming techniques and sample code.

Link to Internet   Link to Server   Explore the COBOL Connection for more examples of COBOL programming techniques and sample code.

Link to Internet   Link to Server   Explore an Extended List of Software Technologies that are available for review and evaluation. The software technologies (or Z-Packs) provide individual programming examples, documentation and test data files in a single package. The Z-Packs are usually in zip format to reduce the amount of time to download.

Link to Internet   Link to Server   Explore The ASCII and EBCDIC Translation Tables. These tables are provided for individuals that need to better understand the bit structures and differences of the encoding formats.

Link to Internet   Link to Server   Explore The File Status Return Codes to interpret the results of accessing VSAM data sets and/or QSAM files.

Table of Contents Previous Section Next Section Internet Access Required

The following links will require an internet connect.

This suite of programs and documentation is available to download for review and evaluation purposes. Other uses will require a SimoTime Software License. Link to an Evaluation zPAK Option that includes the program members, documentation and control files.

A good place to start is The SimoTime Home Page via Internet Connect for access to white papers, program examples and product information.

Explore The Micro Focus Web Site via Internet Connect for more information about products and services available from Micro Focus.

Table of Contents Previous Section Next Section Glossary of Terms

Link to Internet   Link to Server   Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.

Table of Contents Previous Section Next Section Comments or Feedback

This document was created and is copyrighted and maintained by SimoTime Technologies.

If you have any questions, suggestions, comments or feedback please call or send an e-mail to: helpdesk@simotime.com

We appreciate hearing from you.

Table of Contents Previous Section Next Section Company Overview

Founded in 1987, SimoTime Technologies is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems.

Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com


Return-to-Top
Conditional JCL & Parameter Passing to a COBOL Program
Copyright © 1987-2015
SimoTime Technologies
All Rights Reserved
When technology complements business
http://www.simotime.com