JCL Session 8


Temporary Dataset Names


Temporary dataset names
  - start with 2 ampersands followed by at least one letter
- followed by up to 7 additional characters
 
Examples:
  &&SOMENAME
&&A123456
&&WILLCALL
&&DEBTS
 
Temporary datasets
   

Example of creating a temporary file and passing it to a subsequent step.

//SYSUT2 DD DSN=&&THISJOB,DISP=(NEW,PASS),
//       UNIT=DISK,SPACE=(TRK,1),
//       DCB=(RECFM=FB,LRECL=80,BLKSIZE=4000)

If a temporary dataset is not deleted by a JCL statement with DISP=(OLD,DELETE), MVS will delete the tempoary dataset when the job terminates.
 


Concatenated dataset input
Concatenation
  datasets are sequenced one after the other to form one continuous dataset from multiple smaller ones.  

Datasets can be concatenated if they
 

  • all have the same size fixed length record size,
  • are stacked in descending order of blocksize (biggest first, smallest last),
  • are on the same type of unit.
  •  

    TO CONCATENATE DATASETS,
     

    place multiple unnamed DD statements after the DDNAME used for input. So if SYSUT1 is the input ddname, add the additional datasets after the definition of the SYSUT1 ddname.\
     
    Example:
      //SYSUT1 DD  DSN=CSCJHP.CSC.DATA,DISP=OLD   < -- no commas
    //       DD  DSN=CSCJGJ.CSC.DATA,DISP=OLD   < -- no commas
    //       DD  DSN=CSCSMS.CSC.DATA,DISP=OLD
     


    Multistep jobstreams - Programs execute in a series so that the program in first
    step must complete before the second step is started.

    The steps are interdependent since each program in
    a step usually prepares data for the subsequent step
     



    In the following example, a temporary dataset is created in GENSTEP and passed to SORTSTEP. Concatenated datasets are used as input to DD statements in the first 2 steps.



    //JHPJOB JOB 1,'BIN 13 -- PETLICKI',MSGCLASS=X,MSGLEVEL=(1,1)
    //BR14    EXEC PGM=IEFBR14
    //DD1     DD DSN=CCPH00.SORTED.FILE,DISP=(MOD,DELETE),
    //        UNIT=SYSDA,SPACE=(TRK,0) <-- Start with a clean slate
    //*-----------------------------------------------------------
    //GENSTEP EXEC PGM=IEBGENER
    //SYSIN   DD DUMMY
    //SYSUT1  DD DSN=JPETLIC.SAMPDATA,DISP=SHR
    //        DD DSN=CSCJGJ.PREVDATA,DISP=SHR < -- concatenated dataset
    //        DD DSN=CSCSMS.CURRDATA,DISP=SHR < -- concatenated dataset
    //SYSUT2  DD DSN=&&COMBDATA, < -- temporary dataset, used by STEP3
    //        DISP=(NEW,PASS,DELETE), < -- temporaries cannot be CATLG
    //        UNIT=SYSDA,SPACE=(TRK,5),
    //        DCB=(RECFM=FB,LRECL=80,BLKSIZE=4000)
    //SYSPRINT DD SYSOUT=*
    //*-----------------------------------------------------------
    //SORTSTEP EXEC PGM=SORT
    //SYSIN    DD DSN=JPETLIC.CSC.CNTL(SORTSAMP),DISP=OLD
    //SORTIN   DD DSN=&&COMBDATA,DISP=OLD < -- input received from GENSTEP
    //         DD DSN=CSC.TOTPREV,DISP=SHR < -- concatenated dataset
    //         DD DSN=LAS.TOTPREV,DISP=SHR < -- concatenated dataset
    //SORTWK01 DD UNIT=DISK,SPACE=(TRK,1)
    //SORTWK02 DD UNIT=DISK,SPACE=(TRK,1)
    //SYSOUT   DD SYSOUT=*
    //SORTOUT  DD DSN=CCPH00.SORTED.FILE,DISP=(NEW,CATLG,DELETE),
    //         DCB=(RECFM=FB,LRECL=80,BLKSIZE=4000),
    //         UNIT=SYSDA,SPACE=(TRK,(1,1))
    //*-----------------------------------------------------------


    INSTREAM PROCEDURES --
     

    //SAMPLE   JOB XX,'instream PROC',MSGCLASS=X,MSGLEVEL=(1,1)
    //SORTLIST PROC   < -- Statement that defines the start of a procedure
    //*
    //* an instream PROC sample
    //*-----------------------------------------------------------
    //* sort a file
    //*-----------------------------------------------------------
    //SORTSTEP EXEC PGM=SORT
    //SORTIN    DD DSN=CCP.PAYROLL,DISP=SHR
    //          DD DSN=JPETLIC.CSC.CNTL(GRADES),DISP=SHR
    //SORTOUT   DD DSN=&&RESULT,DISP=(NEW,PASS),
    //          DCB=(RECFM=FB,LRECL=80,BLKSIZE=4000),
    //          UNIT=SYSDA
    //SYSIN     DD DSN=CCP.CNTL(PAYSORT) DISP=SHR
    //SYSOUT    DD SYSOUT=*
    //SORTWK01  DD UNIT=SYSDA,SPACE=(TRK,(1,1)
    //SORTWK02  DD UNIT=SYSDA,SPACE=(TRK,(1,1)
    //*-----------------------------------------------------------
    //* print the sorted file
    //*-----------------------------------------------------------
    //GENSTEP  EXEC PGM=IEBGENER
    //SYSUT1    DD DSN=&&RESULT,DISP=(OLD,DELETE)
    //SYSUT2    DD SYSOUT=*
    //SYSPRINT  DD SYSOUT=*
    //SYSIN     DD DUMMY
    //  PEND   < -- Statement that defines the end of a procedure
    //*-----------------------------------------------------------
    //DOIT EXEC PROC=SORTLIST < -- Execute the procedure
    //DOITAGAN EXEC SORTLIST   < -- Execute the procedure


    An instream PROC Illegal JCL statements within the PROC, those between PROC and PEND statements,
    would be the following:
     
  • // JOB statement
  • //JOBLIB statements
  • // < -- the NULL, end of JCL stream, statement
  • //any  DD   *    signifying instream data
  • /*    < -- delimiter
  • JES2 or JES3 statements (/*ROUTE etc, //*FORMAT etc)
  •  


    FINDING STORED PROGRAMS AND PROCEDURES

    SYS1.PROCLIB is the default library that will be searched for procedures.

    When the system reads EXEC PROC=or EXEC, SYS1.PROCLIB is searched unless otherwise indicated.

    If the procedure is not in SYS1.PROCLIB, use a JCLLIB statement immediately after the JOB statement.  The JCLLIB statement should name the library that contains the procedure.



     

    PROCs stored in proc libraries can be executed by other jobs.

    //SAMPLE1 JOB XX,'instream PROC',MSGCLASS=X,MSGLEVEL=(1,1)
    //     JCLLIB ORDER=(CCP.CSC.PROCLIB)
    //DOIT  EXEC PROC=SORTLIST

    //SAMPLE2 JOB XX,'instream PROC',MSGCLASS=X,MSGLEVEL=(1,1)
    //    JCLLIB ORDER=(CCP.CSC.PROCLIB)
    //DOIT2  EXEC SORTLIST



    Rules about PROCs

    1. Every procedure must be a member of a PDS.
        Create a PDS that has the same file attributes as CNTL library.
        (Use JCL or TSO to create a procedure library.
         Name the library your Userid.csc.proclib.)
     
    2. Put procedures into the procedure library.
        Use any utility (iebcopy, tso create, tso copy, or tso edit)
        to create or put procedures into the procedure library.

    3. The following satements should not be in a procedure stored in a procedure library.

      4. Test the PROC


    SYMBOLIC PARAMETERS MAKE PROCS MORE FLEXIBLE AND USEFUL

    1. The procedure could be made more general.

    Replace JCL values with symbolic parameters.

    i.e.              //SORTIN DD DSN=CCP.PAYROLL,DISP=SHR

    could be     //SORTIN DD DSN=&INFILE,DISP=SHR
     

    2. Code default values for the symbolic parameters on the PROC statement. //SORTLIST PROC INFILE='CCP.PAYROLL'

    //SORTLIST PROC INFILE='CCP.PAYROLL'
    //*-----------------------------------------------------------
    //* sort a file
    //*-----------------------------------------------------------
    //SORTSTEP EXEC PGM=SORT
    //SORTIN    DD DSN=&INFILE,DISP=SHR
    //SORTOUT   DD DSN=&&SORTFILE,DISP=(NEW,PASS),
    //          DCB=(RECFM=FB,LRECL=80,BLKSIZE=4000),
    //          UNIT=SYSDA
    //SYSIN     DD DSN=CCP.CNTL(PAYSORT) DISP=SHR
    //SYSOUT    DD SYSOUT=*
    //SORTWK01  DD UNIT=SYSDA,SPACE=(TRK,(1,1)
    //SORTWK02  DD UNIT=SYSDA,SPACE=(TRK,(1,1)
    //*-----------------------------------------------------------
    //* print the sorted file
    //*-----------------------------------------------------------
    //GENSTEP  EXEC PGM=IEBGENER
    //SYSUT1    DD DSN=&&SORTFILE,DISP=(OLD,DELETE)
    //SYSUT2    DD SYSOUT=*
    //SYSPRINT  DD SYSOUT=*
    //SYSIN     DD DUMMY


    The PROCEDURE can be used with default dataset input
    or it can be run with user supplied symbolic changes


    //SAMPLE3  JOB XX,'instream PROC',MSGCLASS=X,MSGLEVEL=(1,1)
    //     JCLLIB ORDER=(CSC.PROCLIB)
    //DOIT EXEC PROC=SORTLIST < -- uses defaults

    //SAMPLE4 JOB XX,'instream PROC',MSGCLASS=X,MSGLEVEL=(1,1)
    //    JCLLIB ORDER=( CSC.PROCLIB)
    //DOIT2 EXEC SORTLIST,INPUT='OLD.PAYROLL' < -- replaces default


    PROC OVERRIDES -

    SORTLIST procedure in CSC.PROCLIB

    //SORTLIST PROC INFILE='CCP.PAYROLL'
    //*-----------------------------------------------------------
    //* sort a file
    //*-----------------------------------------------------------
    //SORTSTEP EXEC PGM=SORT
    //SORTIN    DD DSN=&INFILE,DISP=SHR
    //SORTOUT   DD DSN=&&SORTFILE,DISP=(NEW,PASS),
    //          DCB=(RECFM=FB,LRECL=80,BLKSIZE=4000),
    //          UNIT=SYSDA
    //SYSIN     DD DSN=CCP.CNTL(PAYSORT) DISP=SHR
    //SYSOUT    DD SYSOUT=*
    //SORTWK01  DD UNIT=SYSDA,SPACE=(TRK,(1,1)
    //SORTWK02  DD UNIT=SYSDA,SPACE=(TRK,(1,1)
    //*-----------------------------------------------------------
    //* print the sorted file
    //*-----------------------------------------------------------
    //GENSTEP  EXEC PGM=IEBGENER
    //SYSUT1    DD DSN=&&SORTFILE,DISP=(OLD,DELETE)
    //SYSUT2    DD SYSOUT=*
    //SYSPRINT  DD SYSOUT=*
    //SYSIN     DD DUMMY



    The SORTLIST PROCEDURE from CSC.PROCLIB

    //SAMPLE3 JOB XX,'instream PROC',MSGCLASS=X,MSGLEVEL=(1,1)
    //   JCLLIB ORDER=(CSC.PROCLIB)
    //DOIT   EXEC PROC=SORTLIST
    //SORTSTEP.SYSIN DD * <--- Replaces SYSIN in SORTSTEP
      SORT FIELDS=(1,7,CH,A)
      INCLUDE COND=(32,6,CH,EQ,C'SALARY'),AND,(50,3,CH,GT,000)
    //GENSTEP.SYSUT2 DD SYSOUT=X  <--Overrides output of GENSTEP
    //

    //SAMPLEX JOB XX,'instream PROC',MSGCLASS=X,MSGLEVEL=(1,1)
    //    JCLLIB ORDER=(CSC.PROCLIB)
    //DOIT2   EXEC SORTLIST,INFILE='NEWEST.PAYROLL'
    //SORTSTEP.SORTIN DD DSN=OLDEST.PAYROLL <--- Replaces SORTIN in SORTSTEP



    Question: Which file will be used by the SORTLIST PROC called by the SAMPLEX JOB,

        NEWEST.PAYROLL or OLDEST.PAYROLL ? 


    MORE ON SYMBOLIC PARMS

    //SORT3 PROC PREFIX=JPETLIC,OUTCLASS='*'
    //*-----------------------------------------------------------
    //* sort a file
    //*-----------------------------------------------------------
    //SORTSTEP EXEC PGM=SORT
    //SORTIN    DD DSN=&PREFIX..CSC.CNTL(GRADES),DISP=SHR
    //SORTOUT   DD DSN=&&SORTFILE,DISP=(NEW,PASS),
    //          DCB=(RECFM=FB,LRECL=80,BLKSIZE=4000),
    //          UNIT=SYSDA
    //SYSIN     DD DSN=&PREFIX..CCP.CNTL(PAYSORT) DISP=SHR
    //SYSOUT    DD SYSOUT=*
    //SORTWK01  DD UNIT=SYSDA,SPACE=(TRK,(1,1)
    //SORTWK02  DD UNIT=SYSDA,SPACE=(TRK,(1,1)
    //*-----------------------------------------------------------
    //* print the sorted file
    //*-----------------------------------------------------------
    //GENSTEP  EXEC PGM=IEBGENER
    //SYSUT1    DD DSN=&&SORTFILE,DISP=OLD
    //SYSUT2    DD SYSOUT=&OUTCLASS
    //SYSPRINT  DD SYSOUT=*
    //SYSIN     DD DUMMY



    //SAMPLE3 JOB XX,'instream PROC',MSGCLASS=X,MSGLEVEL=(1,1)
    //   JCLLIB ORDER=(CSC.PROCLIB)
    //DOIT EXEC PROC=SORT3,PREFIX=CCPT00,OUTCLASS='*,COPIES=2'


    EXERCISE (VALUE 30 POINTS)


    Preparation work that should be done (but not handed in to instructor)
     



    Work that should be handed in to instructor.
      The JCL handed in will contain: