You are here: Home > Knowledge Refreshers

KR editions 60 to 63


KR-60: Submit a JCL from within another JCL

  • There may be scenarios where you need to submit a JCL from within another JCL. To do this make use of the TSO Terminal Monitor Program IKJEFT01 (if you remember this was mentioned briefly in an earlier KR). Using this program we can execute TSO commands from a JCL. 

//*A JCL which submits another JCL 

//STEP01 EXEC PGM=IKJEFT01,DYNAMNBR=20 
//SYSOUT DD SYSOUT=* 
//SYSTPRT DD SYSOUT=* 
//SYSTSIN DD * 
SUBMIT 'TEST.JCL.GENERAL(PURGE)' 
//* 

  • The above JCL when submitted would in turn submit the JCL present in the file PURGE.

  • SUBMIT is a TSO command (equivalent to the SUB we type when submitting a JCL). 


KR-61: To check whether a dataset is empty or not in a JCL

There are instances where we need to check whether a dataset is empty or not in a JCL and then conditionally execute some other step. 

IDCAMS provides us with a few simple ways for achieving this. JCL to check for an empty dataset: 

//CHKFILE EXEC PGM=IDCAMS 
//SYSPRINT DD SYSOUT=* 
//FILE DD DSN=TEST.DUMMY,DISP=SHR 
//SYSIN DD * 
PRINT INFILE(FILE) CHARACTER COUNT(1) 
//* 

This basically will attempt to print the first record present in the file (FILE) to SYSPRINT. If the file is empty we'll get a return-code of 4; else it'll be 0. And this return code can be used in the subsequent JCL steps. 


KR-63: Check for an empty dataset using the REPRO command

We can also check for an empty dataset using the REPRO command (normally used for copying). 

Tip contributed by Venkat: 

Here is a sample JCL which can be used to check whether a file is empty. 

//CHKFILE EXEC PGM=IDCAMS 
//SYSPRINT DD SYSOUT=* 
//IN1 DD DSN=TEST.DUMMY.SYSOUT,DISP=SHR
//OUT1 DD DUMMY, 
// DCB=(RECFM=VB,LRECL=2356) 
//SYSIN DD * 
REPRO IFILE(IN1) OFILE(OUT1) COUNT(1) 
/* 

This is an IDCAMS step and if the file (IN1) is empty it returns RC=4.


Go back to the main contents page