Parameter Passing
Access JCL Parameters from COBOL
  Table of Contents  v-24.01.01 - cblpar01.htm 
  Introduction
  Pass a Parameter via PARM=
  The JCL Member using PARM=
  The COBOL Program using PARM=
  Pass Single Parameter via SYSIN
  JCL, SYSIN, Single Parameter
  COBOL, SYSIN, Single Parameter
  Pass Many Parameters via SYSIN
  JCL, SYSIN, Many Parameters
  PDSM, SYSIN, Many Parameters
  COBOL, SYSIN, Many Parameters
  Summary
  Software Agreement and Disclaimer
  Downloads and Links
  Current Server or Internet Access
  Internet Access Required
  Glossary of Terms
  Contact 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 to pass a parameter string from mainframe JCL to a COBOL program. The COBOL program is written using COBOL/2 dialect but also works with COBOL for MVS and COBOL/370. A JCL member is provided to run the job as an MVS batch job on an IBM mainframe or as a job with Micro Focus Server running on Linux, UNIX or Windows. This program may serve as a tutorial for programmers that are new to COBOL and mainframe JCL and as a reference for experienced programmers.

The two techniques use to pass information (a Parameter) from JCL to a program are as follows.

Technique Description
via PARM= This technique uses a PARM=parameter keyword on the EXEC statement in JCL. The COBOL program requires a LINKAGE SECTION.
via SYSIN This technique requires a SYSIN statement followed by the parameter to be placed in the JCL. The COBOL program requires an "ACCEPT parameter from SYSIN" to be coded in the COBOL program. If the SYSIN statement is missing in the JCL the ACCEPT will ABEND with a "File not found" message. To avoid this it will be necessary to use a "//SYSIN DD DUMMY" statement in the JCL when a parameter is not being passed.
  Techniques used to pass a Parameter from JCL to a Program

The following sections will explain the parameter-passing in more detail.


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-2025
SimoTime Technologies and Services
All Rights Reserved

Table of Contents Previous Section Next Section Pass a Parameter via PARM=

To pass a parameter from JCL to a program requires the use of the "PARM=" keyword with the EXEC statement. The following JCL statement shows an EXEC statement without a parameter defined.

Table of Contents Previous Section Next Section The JCL Member using PARM=

The following is the JCL member (CBLPARJ1.jcl) required to run as a job on the mainframe. This will also run on a Linux, UNIX or Windows environment using Micro Focus Server. The job contains four steps. The first step will execute the COBOL program (CBLPARC1.cbl) without passing a parameter. The second step will execute the COBOL program and pass a parameter. The third step will execute the COBOL program and pass a maximum size parameter. The fourth step will execute the COBOL program and pass a parameter using a substitution variable for a date value. The JOB statement will need to be modified for specific mainframe environments.

//CBLPARJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*       CBLPARJ1.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2019 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.
//*
//* This set of programs may be compiled and executed on a Mainframe
//* System with ZOS or a Linux, UNIX or Windows System with Micro Focus
//* Enterprise Server.
//*
//* *******************************************************************
//* Step 1 of 4, Execute the COBOL program without a parameter.
//*
//PARJ1S01 EXEC PGM=CBLPARC1
//*
//* *******************************************************************
//* Step 2 of 4, Execute the COBOL program with a parameter.
//*
//PARJ1S02 EXEC PGM=CBLPARC1,
//             PARM='This is a Parameter from the EXEC and PARM= ...'
//*
//* *******************************************************************
//* Step 3 of 4, Execute the COBOL program with a parameter.
//*              The PARM= has a record length maximum of 100.
//*
//PARJ1S03 EXEC PGM=CBLPARC1,
//             PARM='....:....1....:....2....:....3....:....4....:....5X
//             ....:....6....:....7....:....9....:...10....:...11'
//*
//* *******************************************************************
//* Step 4 of 4, Execute the COBOL program with a parameter.
//*              The PARM= has a substitution variable.
//*
//         SET SYSDATE=20051013
//PARJ1S04 EXEC PGM=CBLPARC1,PARM='DATE IS &SYSDATE'
//

Table of Contents Previous Section Next Section The COBOL Program using PARM=

This program (CBLPARC1.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.

//CBLPARS2 EXEC PGM=CBLPARC1,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.    CBLPARC1.
       AUTHOR.        SIMOTIME TECHNOLOGIES.
      *****************************************************************
      * Copyright (C) 1987-2019 SimoTime Technologies.                *
      *                                                               *
      * 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    *
      * Technologies.                                                 *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any commercial purpose requires a fee to be paid to       *
      * SimoTime Technologies. 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           *
      * Technologies.                                                 *
      *                                                               *
      * SimoTime Technologies 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       *
      * Technologies 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 Technologies                                         *
      * 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 Technologies, *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *****************************************************************
      *
      *****************************************************************
      * Source Member: CBLPARC1.CBL
      *****************************************************************
      *
      * CBLPARC1 - 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 '* CBLPARC1 '.
           05  T2 pic X(34) value 'Sample, Process a JCL Parameter   '.
           05  T3 pic X(10) value ' v03.12.02'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CBLPARC1 '.
           05  C2 pic X(20) value 'Copyright 1987-2019 '.
           05  C3 pic X(28) value '   SimoTime Technologies    '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* CBLPARC1 '.
           05  C2 pic X(32) value 'Thank you for using this program'.
           05  C3 pic X(32) value ' provided from SimoTime Technolo'.
           05  C4 pic X(04) value 'gies'.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* CBLPARC1 '.
           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 '* CBLPARC1 '.
           05  MESSAGE-TEXT        pic X(128).

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

      *****************************************************************
       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

           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
               perform Z-POST-MESSAGE
           end-if

           perform Z-THANK-YOU.

           GOBACK.

      *****************************************************************
      *    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 Technologies        *
      *        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 Pass Single Parameter via SYSIN

To pass a parameter from SYSIN to a program requires the use of DD statement for SYSIN. The following JCL statement is required if no parameter is passed.

//* *******************************************************************
//* Step   1 of 2, Execute the COBOL program without a parameter.
//*
//SYSIN DD DUMMY

Table of Contents Previous Section Next Section JCL, SYSIN, Single Parameter

The following is the JCL member (CBLPARJ2.jcl) required to run as a job on the mainframe. This will also run on a Linux, UNIX or Windows environment using Micro Focus Server. The job contains two steps. The first step will execute the COBOL program (CBLPARC2.cbl) without passing a parameter. The second step will execute the COBOL program and pass a parameter. The JOB statement will need to be modified for specific mainframe environments.

//CBLPARJ2 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*       CBLPARJ2.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2019 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 SYSIN.
//*
//* This set of programs may be compiled and executed on a Mainframe
//* System with ZOS or a Linux, UNIX or Windows System with Micro Focus
//* Enterprise Server.
//*
//* *******************************************************************
//* Step 1 of 2, Execute the COBOL program without a parameter.
//*
//*        The //SYSIN DD DUMMY is required to prevent the COBOL
//*        program from ABENDING on the ACCEPT ... from SYSIN.
//*
//PARJ2S01 EXEC PGM=CBLPARC2
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB,DISP=SHR
//SYSIN DD DUMMY
//*
//* *******************************************************************
//* Step 2 of 2, Execute the COBOL program with a parameter.
//*
//PARJ2S02 EXEC PGM=CBLPARC2
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB,DISP=SHR
//SYSIN    DD *
This is a single parameter from CBLPARJ2 and SYSIN-DD-* ...
/*
//*
//

Table of Contents Previous Section Next Section COBOL, SYSIN, Single Parameter

The following is the COBOL program (CBLPARC2.cbl) required to run as a job on the mainline. This will also run on the PC using Mainframe Express provided by Micro Focus. The job contains two steps. The first step will execute the COBOL program (CBLPARC2.cbl) without passing a parameter. The second step will execute the COBOL program and pass a parameter via SYSIN. The JOB statement will need to be modified for specific mainframe environments.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CBLPARC2.
       AUTHOR.        SIMOTIME TECHNOLOGIES.
      *****************************************************************
      * Copyright (C) 1987-2019 SimoTime Technologies.                *
      *                                                               *
      * 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    *
      * Technologies.                                                 *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any commercial purpose requires a fee to be paid to       *
      * SimoTime Technologies. 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           *
      * Technologies.                                                 *
      *                                                               *
      * SimoTime Technologies 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       *
      * Technologies 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 Technologies                                         *
      * 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 Technologies, *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *****************************************************************
      *
      *****************************************************************
      * Source Member: CBLPARC2.CBL
      *****************************************************************
      *
      * CBLPARC2 - This program will process a SYSIN parameter.
      *
      * CALLING PROTOCOL
      * ----------------
      * USE STANDARD PROCEDURE TO EXECUTE, RUN OR ANIMATE.
      *
      * DESCRIPTION
      * -----------
      * This program will process the JCL parameter from SYSIN.
      *
      * //SYSIN   DD  *
      * Parameter from SYSIN...
      * //*
      *
      * or a DUMMY is required to avoid an ABEND on the ACCEPT...
      *
      * //SYSIN   DD DUMMY
      *
      * 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 '* CBLPARC2 '.
           05  T2 pic X(34) value 'Sample, Process SYSIN Parameter   '.
           05  T3 pic X(10) value ' v03.12.02'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CBLPARC2 '.
           05  C2 pic X(20) value 'Copyright 1987-2019 '.
           05  C3 pic X(28) value '   SimoTime Technologies    '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* CBLPARC2 '.
           05  C2 pic X(32) value 'Thank you for using this program'.
           05  C3 pic X(32) value ' provided from SimoTime Technolo'.
           05  C4 pic X(04) value 'gies'.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* CBLPARC2 '.
           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 '* CBLPARC2 '.
           05  MESSAGE-TEXT        pic X(128).

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

       01  SYSIN-PARAMETER         pic X(80)  value SPACES.
       01  SYSIN-LENGTH            pic 9(5)    value 0.

       01  IX-1                    pic 9(3)    value 0.

      *****************************************************************
       PROCEDURE DIVISION.
           if  FIRST-TIME not = 'N'
               perform Z-POST-COPYRIGHT
               move 'N' to FIRST-TIME
      *>       A DD statement is required or a hard ABEND will occur
      *>       on the ACCEPT. If no parameters are passed then a
      *>       //SYSIN DD DUMMY is required to prevent the COBOL
      *>       program from ABENDING on the ACCEPT ... from SYSIN.
               accept SYSIN-PARAMETER from SYSIN
           end-if

           subtract SYSIN-LENGTH from SYSIN-LENGTH
           if  SYSIN-PARAMETER = SPACES
               add SYSIN-LENGTH to ZERO giving JCL-PARM-LENGTH
               move MESSAGE-TEXT-01 to MESSAGE-TEXT
               perform Z-POST-MESSAGE
           else
               perform CALCULATE-TEXT-LENGTH
               add SYSIN-LENGTH to ZERO giving JCL-PARM-LENGTH
               move MESSAGE-TEXT-01 to MESSAGE-TEXT
               perform Z-POST-MESSAGE
               move SYSIN-PARAMETER  to MESSAGE-TEXT
               perform Z-POST-MESSAGE
           end-if

           perform Z-THANK-YOU.

           GOBACK.

      *****************************************************************
       CALCULATE-TEXT-LENGTH.
           add 1 to ZERO giving IX-1
           perform 80 times
               if  SYSIN-PARAMETER(IX-1:1) not = SPACE
                   add IX-1 to ZERO giving SYSIN-LENGTH
               end-if
               add 1 to IX-1
           end-perform
           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 Technologies        *
      *        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 Pass Many Parameters via SYSIN

To pass multiple parameters (or records) from SYSIN to a program requires the use of DD statement for SYSIN. The following JCL statement is required if no parameter is passed.

//* *******************************************************************
//* Step   1 of 2, Execute the COBOL program without a parameter.
//*
//SYSIN DD DUMMY

Table of Contents Previous Section Next Section JCL, SYSIN, Many Parameters

The following is the JCL member (CBLPARJ3.jcl) required to run as a job on the mainframe. This will also run on a Linux, UNIX or Windows environment using Micro Focus Server. The job contains three steps. The first step will execute the COBOL program (CBLPARC3.cbl) without passing a parameter. The second step will execute the COBOL program and pass three parameters as instream data. The third step will execute the COBOL program and pass five parameters using a PDS Member from the PARMLIB. The JOB statement will need to be modified for specific mainframe environments.

//CBLPARJ3 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*       CBLPARJ3.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2019 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 SYSIN.
//*
//* This set of programs may be compiled and executed on a Mainframe
//* System with ZOS or a Linux, UNIX or Windows System with Micro Focus
//* Enterprise Server.
//*
//* *******************************************************************
//* Step 1 of 3, Execute the COBOL program without a parameter.
//*
//*        The //SYSIN DD DUMMY is required to prevent the COBOL
//*        program from ABENDING on the ACCEPT ... from SYSIN.
//*
//PARJ3S01 EXEC PGM=CBLPARC3
//SYSIN DD DUMMY
//*
//* *******************************************************************
//* Step 2 of 3, Execute the COBOL program with multiple parameters.
//*
//PARJ3S02 EXEC PGM=CBLPARC3
//SYSIN    DD *
This is Parameter 01 from CBLPARJ3 and SYSIN-DD-*.
This is Parameter 02 from CBLPARJ3 and SYSIN-DD-*..
This is Parameter 03 from CBLPARJ3 and SYSIN-DD-*...
/*
//*
//* *******************************************************************
//* Step 3 of 3, Execute the COBOL program using a PDS Member.
//*
//PARJ3S03 EXEC PGM=CBLPARC3
//SYSIN    DD  DISP=SHR,DSN=SIMOTIME.PDS.PARMLIB(CBLPARS3)
//*
//

Table of Contents Previous Section Next Section PDSM, SYSIN, Many Parameters

The parameters are stored in a Partitioned Data Set Member or PDSM. The following is the content of the PDS Member (CBLPARS3.ctl) used to provide parameters via the SYSIN statement in the JCL member.

This is Parameter 01 from CBLPARS3 in PARMLIB, a PDSM...1
This is Parameter 02 from CBLPARS3 in PARMLIB, a PDSM...02
This is Parameter 03 from CBLPARS3 in PARMLIB, a PDSM...003
This is Parameter 04 from CBLPARS3 in PARMLIB, a PDSM...0004
This is Parameter 05 from CBLPARS3 in PARMLIB, a PDSM...00005

Table of Contents Previous Section Next Section COBOL, SYSIN, Many Parameters

The following is the COBOL program (CBLPARC3.cbl) required to run as a job on the mainline. This will also run on the PC using Mainframe Express provided by Micro Focus. The job contains two steps. The first step will execute the COBOL program (CBLPARC3.CBL) without passing a parameter. The second step will execute the COBOL program and pass a parameter via SYSIN. The JOB statement will need to be modified for specific mainframe environments.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CBLPARC3.
       AUTHOR.        SIMOTIME TECHNOLOGIES.
      *****************************************************************
      * Copyright (C) 1987-2019 SimoTime Technologies.                *
      *                                                               *
      * 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    *
      * Technologies.                                                 *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any commercial purpose requires a fee to be paid to       *
      * SimoTime Technologies. 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           *
      * Technologies.                                                 *
      *                                                               *
      * SimoTime Technologies 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       *
      * Technologies 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 Technologies                                         *
      * 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 Technologies, *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *****************************************************************
      *
      *****************************************************************
      * Source Member: CBLPARC3.CBL
      *****************************************************************
      *
      * CBLPARC3 - This program will process a SYSIN parameter.
      *
      * CALLING PROTOCOL
      * ----------------
      * USE STANDARD PROCEDURE TO EXECUTE, RUN OR ANIMATE.
      *
      * DESCRIPTION
      * -----------
      * This program will process the JCL parameter from SYSIN.
      *
      * //SYSIN   DD  *
      * Parameter from SYSIN...
      * //*
      *
      * or a DUMMY is required to avoid an ABEND on the ACCEPT...
      *
      * //SYSIN   DD DUMMY
      *
      * 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 '* CBLPARC3 '.
           05  T2 pic X(34) value 'Sample, Process SYSIN Parameter   '.
           05  T3 pic X(10) value ' v03.12.02'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CBLPARC3 '.
           05  C2 pic X(20) value 'Copyright 1987-2019 '.
           05  C3 pic X(28) value '   SimoTime Technologies    '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* CBLPARC3 '.
           05  C2 pic X(32) value 'Thank you for using this program'.
           05  C3 pic X(32) value ' provided from SimoTime Technolo'.
           05  C4 pic X(04) value 'gies'.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* CBLPARC3 '.
           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 '* CBLPARC3 '.
           05  MESSAGE-TEXT        pic X(128).

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

       01  SYSIN-PARAMETER         pic X(80)   value SPACES.
       01  SYSIN-LENGTH            pic 9(5)    value 0.

       01  IX-1                    pic 9(3)    value 0.


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

           perform 10 times
               move SPACES to SYSIN-PARAMETER
      *!       A DD statement is required or a hard ABEND will occur
      *!       on the ACCEPT. If no parameters are passed then a
      *!       //SYSIN DD DUMMY is required to prevent the COBOL
      *!       program from ABENDING on the ACCEPT ... from SYSIN.
      *!       Since there is no File Status code for the accept then
      *!       an ACCEPT after the final record is read from SYSIN
      *!       will leave the buffer in the state before the request.
      *!       In this example the buffer is always initialized with
      *!       space characters and the logic in the program will
      *!       determine a ZERO record length and the routine should
      *!       stop accepting (or reading) from SYSIN. The following
      *!       example intentionally reads (or accepts) beyond the
      *!       SYSIN records available to show a technique for
      *!       handling this possibility.
               accept SYSIN-PARAMETER from SYSIN
               subtract SYSIN-LENGTH from SYSIN-LENGTH
               if  SYSIN-PARAMETER = SPACES
                   add SYSIN-LENGTH to ZERO giving JCL-PARM-LENGTH
                   move MESSAGE-TEXT-01 to MESSAGE-TEXT
                   perform Z-POST-MESSAGE
               else
                   perform CALCULATE-TEXT-LENGTH
                   add SYSIN-LENGTH to ZERO giving JCL-PARM-LENGTH
                   move MESSAGE-TEXT-01 to MESSAGE-TEXT
                   perform Z-POST-MESSAGE
                   move SYSIN-PARAMETER  to MESSAGE-TEXT
                   perform Z-POST-MESSAGE
               end-if
           end-perform

           perform Z-THANK-YOU.

           GOBACK.

      *****************************************************************
       CALCULATE-TEXT-LENGTH.
           add 1 to ZERO giving IX-1
           inspect SYSIN-PARAMETER replacing all LOW-VALUES by SPACES
           perform 80 times
               if  SYSIN-PARAMETER(IX-1:1) not = SPACE
                   add IX-1 to ZERO giving SYSIN-LENGTH
               end-if
               add 1 to IX-1
           end-perform
           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 Technologies        *
      *        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

This group of jobs and documentation is intended to help the reader develop a better understanding of how to pass a parameter string from mainframe JCL to a COBOL program. This document may be used 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 documentation and software were developed and tested on systems that are configured for a SIMOTIME environment based on the hardware, operating systems, user requirements and security requirements. Therefore, adjustments may be needed to execute the jobs and programs when transferred to a system of a different architecture or configuration.

SIMOTIME Services has experience in moving or sharing data or application processing across a variety of systems. For additional information about SIMOTIME Services or Technologies please contact us using the information in the  Contact or Feedback  section of this document.

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 Technologies. 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 Technologies.

SimoTime Technologies 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 Technologies 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 Parameter Passing and Conditional Processing with JCL. This example passes parameters from JCL to COBOL and the Job Step execution is determined by the Condition Code set by the COBOL program.

Link to Internet   Link to Server   Explore the Pass, Parse and Convert Data Strings that has examples of using COBOL for passing a parameter from JCL to COBOL plus other translation and parsing routines.

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 that are used 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 connection.

This suite of programs and documentation is available for download. 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 for access to white papers, program examples and product information. This link requires an Internet Connection

Explore The Micro Focus Web Site for more information about products (including Micro Focus COBOL) and services available from Micro Focus. This link requires an Internet Connection.

Explore the GnuCOBOL Technologies available from SourceForge. SourceForge is an Open Source community resource dedicated to helping open source projects be as successful as possible. GnuCOBOL (formerly OpenCOBOL) is a COBOL compiler with run time support. The compiler (cobc) translates COBOL source to executable using intermediate C, designated C compiler and linker. This link will require an Internet Connection.

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 Contact or Feedback

This document was created and is maintained by SimoTime Technologies. If you have any questions, suggestions, comments or feedback please use the following contact information.

1. Send an e-mail to our helpdesk.
1.1. helpdesk@simotime.com.
2. Our telephone numbers are as follows.
2.1. 1 415 763-9430 office-helpdesk
2.2. 1 415 827-7045 mobile

 

We appreciate hearing from you.

Table of Contents Previous Section Next Section Company Overview

SimoTime Technologies was founded in 1987 and 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. Our customers include small businesses using Internet technologies to corporations using very large mainframe systems.

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. We specialize in preparing applications and the associated data that are currently residing on a single platform to be distributed across a variety of platforms.

Preparing the application programs will require the transfer of source members that will be compiled and deployed on the target platform. The data will need to be transferred between the systems and may need to be converted and validated at various stages within the process. SimoTime has the technology, services and experience to assist in the application and data management tasks involved with doing business in a multi-system environment.

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
Passing JCL Parameters to a COBOL Program via LINKAGE or ACCEPT and SYSIN
Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com