JCL script examples

This section presents examples of JCL scripts.

JCL script example 1

000001 /******************************************************************
000002 /* 
000003 /* Script:  EXAMPLE   A sample script to illustrate the JCL generator.
000004 /* It is a primary script, not a sub-routine script.
000005 /* 
000006 /* Author     YYYYMMDD Description 
000007 /* ---------- -------- --------------------------------------------
000008 /* JCL Writer 20000401 Initial creation as a sample JCL script 
000009 /******************************************************************
000010 script example 
000011 
000012 /*-----------------------------------------------------------------
000013 /*~ 1.  Perform initialization processing 
000014 /*-----------------------------------------------------------------
000015   call script = @first     /* sets up variables common to all scripts
000016   call script = @jobcard   /* builds and inserts the job statement 
000017   call script = @steplib   /* builds an array of STEPLIB datasets 
000018 
000019 /*-----------------------------------------------------------------
000020 /*~ 2.  Build the body of the JCL 
000021 /*-----------------------------------------------------------------
000022   jcl gen                             /* 1st step deletes files 
000023 //* 
000024 //DELETE   EXEC PGM=IEFBR14 
000025 //REPTFL1  DD  DSN=&SYSUID..BMCSCRIPT.&SYSJOBID..WORK1, 
000026 //             DISP=(MOD,DELETE),UNIT=&F_DASD_UNIT, 
000027 //             DCB=(LRECL=133,BLKSIZE=13300,RECFM=FBA), 
000028 //             SPACE=(TRK,(1,1)) 
000029   endjcl 
000030 
000031   substr dd = &sysndate (1,2)         /* DD in DDMMYY 
000032   translate monthly_report_reqd = &dd /* Monthly report required? 
000033             ('01'  'YES')             /* YES if 1st day of month 
000034             (&dd   'NO')              /* NO for all other days 
000035   jcl gen                             /* 2nd step is user program 
000036 //* 
000037 //REPORT   EXEC PGM=PROGRAM1,PARM=('DEFINE','REPORT') 
000038 //REPTFL1  DD  DSN=&SYSUID..BMCSCRIPT.&SYSJOBID..WORK1, 
000039 //             DISP=(NEW,CATLG),UNIT=&F_DASD_UNIT, 
000040 //             DCB=(LRECL=133,BLKSIZE=13300,RECFM=FBA), 
000041 //             SPACE=(TRK,(3,1)) 
000042 //INFILE   DD  SYSIN=* 
000043 DAILY    YES 
000044 MONTHLY  &MONTHLY_REPORT_REQD 
000045 /* 
000046   endjcl 
000047   let stepdd  = 'STEPLIB'             /* set the DDname to STEPLIB 
000048   do x1 = 1 to dimension(steplib)     /* loop thru each entry. 
000049     jcl gen                           /* Build JCL for STEPLIBs 
000050 //&STEPDD  DD  DISP=SHR,DSN=&STEPLIB:&X1 
000051     endjcl 
000052     let stepdd  = ' '                 /* Reset the DDname to blank 
000053   enddo 
000054 /*---------------------------------------------------------------- 
000055 /*~ 3.  Perform any windup processing 
000056 /*---------------------------------------------------------------- 
000057   call script = @last                 /* writes completion messages 
000058 
000059 endscript

JCL script example 2

000001 /******************************************************************
000002 /* 
000003 /*  Script: @FIRST    Initial script used to set up working variables
000004 /*                    common to all other scripts. 
000005 /* 
000006 /* Author     YYYYMMDD Description 
000007 /* ---------- -------- --------------------------------------------
000008 /* JCL Writer 20000401 Initial creation as a script to set up variables
000009 /******************************************************************
000010 script @first 
000011 
000012 /*-----------------------------------------------------------------
000013 /*~ 1.  Set up common working variables 
000014 /*-----------------------------------------------------------------
000015 
000016 /* Note:  An F_ prefix has been added to the common variables 
000017 /*        defined in @FIRST. 
000018 
000019   let f_dasd_unit    = 'SYSDA'            /* The DASD unit device 
000020   let f_tape_unit    = 'CART'             /* The tape unit device 
000021   let f_cart_unit    = 'CART'          /* The cartridge unit device
000022   let f_sysout_class = '*'                /* SYSOUT=? on DD statement
000023 
000024   let f_job_account= 'ACCOUNT CODE'     /* Job card ACCOUNT value
000025   let f_job_class    = 'A'                /* Job card CLASS value 
000026   let f_job_msgclass = 'X'                /* Job card MSGCLASS value
000027   let f_job_notify   = &sysuid            /* Job card NOTIFY value 
000028 
000029   let f_user_lib     = 'CUSTOMER.LOADLIB' /* DSN for user programs 
000030   let f_db2_lib      = ' '                /* DSN for DB2 (not used) 
000031   let f_ims_lib      = 'IMS610.LOADLIB'   /* DSN for IMS 
000032   let f_system_lib   = 'SYS1.LINKLIB'     /* DSN for system programs 
000033 
000034 /*-----------------------------------------------------------------
000035 /*~ 2.  Log a message indicating that processing has started 
000036 /*-----------------------------------------------------------------
000037 
000038   substr hh = &systime (1,2)     /* the HH in HHMMSS 
000039   substr mm = &systime (3,2)     /* the MM in HHMMSS 
000040   substr ss = &systime (5,2)     /* the SS in HHMMSS 
000041 
000042   let time = &hh || ':' || &mm || ':' || &ss 
000043 
000044   msg info 'JCL Script ' 
000045         || &syscommand 
000046         || ' invoked by user '' 
000047         || &sysuid 
000048         || '' on ' 
000049         || &sysdate 
000050         || ' at ' 
000051         || &time 
000052 
000053 endscript

JCL script example 3

000001 /**********************************************************************
000002 /* 
000003 /*  Script: @JOBCARD  Build the JCL job card. 
000004 /* 
000005 /* Author     YYYYMMDD Description 
000006 /* ---------- -------- --------------------------------------------
000007 /* JCL Writer 20000401 Initial creation to build the JCL job card 
000008 /******************************************************************
000009 script @jobcard 
000010 
000011 /*-----------------------------------------------------------------
000012 /*~ 1.  Add JOB, ACCOUNT and NAME parameters 
000013 /*-----------------------------------------------------------------
000014 
000015   substr jobn = &sysuid || 'JCLSCRIPT' (1,8) 
000016 
000017   jcl gen 
000018 //&JOBN    JOB (&F_JOB_ACCOUNT),'BMC JCL SCRIPT', 
000019 //         NOTIFY=&SYSUID, 
000020 //         CLASS=&F_JOB_CLASS,MSGCLASS=&F_JOB_MSGCLASS 
000021   endjcl 
000022 
000023 endscript

JCL script example 4

000001 /******************************************************************
000002 /* 
000003 /*  Script: @STEPLIB  Create an array of STEPLIB datasets. 
000004 /* 
000005 /* Author     YYYYMMDD Description 
000006 /* ---------- -------- --------------------------------------------
000007 /* JCL Writer 20000401 Initial creation to build an array of STEPLIBs 
000008 /******************************************************************
000009 script @steplib 
000010 
000011 /*-----------------------------------------------------------------
000012 /*~ 1.  Set up STEPLIB a 1 dimensional array 
000013 /*-----------------------------------------------------------------
000014 
000015   let x1 = 1                            /* Set index pointer to 1 
000016 
000017   if &f_db2_lib = ' '                   /* If DB2 is used 
000018     let steplib:&x1 = &f_db2_lib        /* set the DSN name 
000019     let x1 = &x1 + 1                    /* increment array pointer 
000020   endif 
000021 
000022   if &f_ims_lib = ' '                   /* If IMS is used 
000023     let steplib:&x1 = &f_ims_lib        /* set the DSN name 
000024     let x1 = &x1 + 1                    /* increment array pointer 
000025   endif 
000026 
000027   if &f_system_lib = ' '                /* If a system lib is used 
000028     let steplib:&x1 = &f_system_lib     /* set the DSN name 
000029     let x1 = &x1 + 1                    /* increment array pointer 
000030   endif 
000031 
000032   if &f_user_lib = ' '                  /* If a user lib is used 
000033     let steplib:&x1 = &f_user_lib       /* set the DSN name 
000034     let x1 = &x1 + 1                    /* increment array pointer 
000035   endif 
000036 
000037 endscript

JCL script example 5

000001 /******************************************************************
000002 /* 
000003 /*  Script: @LAST     Write out script completion message. 
000004 /* 
000005 /* Author     YYYYMMDD Description 
000006 /* ---------- -------- --------------------------------------------
000007 /* JCL Writer 20000401 Initial creation to write out a completion msg
000008 /******************************************************************
000009 script @last 
000010 
000011 /*-----------------------------------------------------------------
000012 /*~ 1.  Log a message indicating that processing has completed 
000013 /*-----------------------------------------------------------------
000014 
000015   substr hh = &systime (1,2)     /* the HH in HHMMSS 
000016   substr mm = &systime (3,2)     /* the MM in HHMMSS 
000017   substr ss = &systime (5,2)     /* the SS in HHMMSS 
000018 
000019   let time = &hh || ':' || &mm || ':' || &ss 
000020 
000021   msg info 'JCL Script ' 
000022         || &syscommand 
000023         || ' completed RC=' 
000024         || &sysrc 
000025         || ' on ' 
000026         || &sysdate 
000027         || ' at ' 
000028         || &time 
000029 
000030 endscript

Was this page helpful? Yes No Submitting... Thank you

Comments