Search code examples
mainframejclrexx

How to use parameters in JCL


I try to submit job, and all is good, when i hard coding. But I want to use params.

//REPORTS   EXEC PGM=IKJEFT01,**PARM='SDSFINFO FTPSRV01 * hiqual'**
//SYSEXEC   DD DSN=rexx.is.here,DISP=(SHR,PASS)                 
//SYSTSPRT  DD SYSOUT=A,HOLD=YES                               
//SYSTSIN   DD DUMMY                                           

I write my JCL as Procedure. Is it real to describe parameters in the procedure invoice ? Like this:

  //stepxx  exec myproc,hiqual=hiqual,owner=*...

Solution

  • There are two kinds of procedure, cataloged procedure and in-stream procedure.

    A cataloged procedure is stored in a library member separate from the execution JCL. This separate library is located by the system searching through a list of such libraries defined to it in SYS1.PARMLIB. This list can be overridden with the JCLLIB statement in the execution JCL. Your shop likely has a standard location where cataloged procedures are stored.

    In-stream procedures are located in the same library member as your execution JCL. The PROC statement must be between your jobcard and the EXEC statement that executes the named proc. The in-stream procedure must end with a PEND statement.

    It is common to use symbolic parameters with procedures, making them more flexible.

    You're headed in the right direction...

    [jobcard is here]
    //MYPROC    PROC 
    //REPORTS   EXEC PGM=IKJEFT01,PARM='SDSFINFO FTPSRV01 &OWNER &HIQUAL'
    //SYSEXEC   DD DSN=[rexx.is.here],DISP=(SHR,PASS)
    //SYSTSPRT  DD SYSOUT=A,HOLD=YES
    //SYSTSIN   DD DUMMY
    //          PEND
    //*
    //MYSTEP    EXEC PROC=MYPROC,HIQUAL=ABC,OWNER=XYZ
    

    ...where the stuff in square brackets must be supplied by you. This will result in MYPROC being executed as if you had hardcoded...

    //REPORTS   EXEC PGM=IKJEFT01,PARM='SDSFINFO FTPSRV01 XYZ ABC'
    //SYSEXEC   DD DSN=[rexx.is.here],DISP=(SHR,PASS)
    //SYSTSPRT  DD SYSOUT=A,HOLD=YES
    //SYSTSIN   DD DUMMY
    

    Sometimes procs are coded with default values for symbolic parameters...

    //MYPROC    PROC ENV='PROD'
    //REPORTS   EXEC PGM=IKJEFT01,PARM='SDSFINFO FTPSRV01 &OWNER &HIQUAL'
    //SYSEXEC   DD DSN=&ENV..REXX,DISP=(SHR,PASS)
    //SYSTSPRT  DD SYSOUT=A,HOLD=YES
    //SYSTSIN   DD DUMMY
    

    ...and sometimes the default value is documentation...

    //MYPROC    PROC ENV='SPECIFY_PROD_OR_TEST_OR_QA'
    //REPORTS   EXEC PGM=IKJEFT01,PARM='SDSFINFO FTPSRV01 &OWNER &HIQUAL'
    //SYSEXEC   DD DSN=&ENV..REXX,DISP=(SHR,PASS)
    //SYSTSPRT  DD SYSOUT=A,HOLD=YES
    //SYSTSIN   DD DUMMY
    

    ...forcing the execution JCL to provide a value or suffer a JCL error at run time.

    Note that with the SET statement you can use symbolic parameters without needing a procedure, cataloged or in-stream. This...

    [jobcard is here]
    //  SET HIQUAL=ABC
    //  SET OWNER=XYZ
    //*
    //REPORTS   EXEC PGM=IKJEFT01,PARM='SDSFINFO FTPSRV01 &OWNER &HIQUAL'
    //SYSEXEC   DD DSN=[rexx.is.here],DISP=(SHR,PASS)
    //SYSTSPRT  DD SYSOUT=A,HOLD=YES
    //SYSTSIN   DD DUMMY
    //*
    

    ...will give the same results as the first example, without using a proc.

    There are usually shop standards to which you will be expected to adhere. Often mainframe shops have a dedicated group whose function is to run production job streams, scheduling hundreds or thousands of such job streams per day.