JCL Interview Questions and Answers (41 - 50)

41. Can you code instream data in a PROC?

No, instream data (data included directly within the JCL) cannot be coded within a procedure (PROC). Procedures are designed to be reusable and instream data would make them less flexible. Instead, you can pass data to procedures using other methods, such as datasets or symbolic parameters.

42. Is it possible to submit JCL from COBOL?

Yes, it is possible to submit JCL from a COBOL program by writing the JCL statements to the Internal Reader (INTRDR) using a spool file.

Steps to Submit JCL from COBOL:

  • Define an internal reader (SYSOUT=(*,INTRDR)) in JCL:
    //OUTFILE DD SYSOUT=(*,INTRDR)
  • Write JCL statements from COBOL to this file using WRITE statements:
    ...
        SELECT FILE ASSIGN TO OUTFILE.
    ...
    FD  FILE.
    01  OUTREC PIC X(80).
    ...
    PROCEDURE DIVISION USING LK-DATA.
        ...
        OPEN OUTPUT OUTFILE.
        MOVE "//MYJOB JOB (12345),'TEST JOB'" 
    	  TO OUTREC.
        WRITE OUTREC.
        MOVE '//STEP1 EXEC PGM=IEFBR14' TO OUTREC.
        WRITE OUTREC.
        CLOSE OUTFILE.
    	...

43. What do you mean by the INCLUDE statement in JCL?

The INCLUDE statement in JCL is used to insert reusable JCL code from an external member into a job. It helps in reducing redundancy and improving maintainability.

Example -

The following INCLUDE group is defined in member SYSOUT2 of private library MATEPK.TEST.JCLLIB.

//*  THIS INCLUDE GROUP IS CATALOGED AS...
//*  MATEPK.TEST.JCLLIB(TESTPARM)
//TESTPARM  DD    SYSOUT=A
//          SET  GROUPID=MATEPK
//          SET  REGION=TEST1
//*  END OF INCLUDE GROUP...
//*  MATEPK.TEST.JCLLIB(TESTPARM)

The system executes the following program:

//TESTJOB  JOB  ...
//LIBSRCH  JCLLIB  ORDER=MATEPK.TEST.JCLLIB
//OUTPUT1  INCLUDE MEMBER=TESTPARM
//STEP1    EXEC    PGM=PROG1
//STEP2    EXEC    PGM=IEFBR14

44. What are the statements that are not valid to be included in an INCLUDE statement?

Certain statements cannot be coded within an INCLUDE member, including:

  • Dummy DD statements
  • Data card specifications
  • PROCs (procedures)
  • JOB statements
  • PROC statements

However, an INCLUDE statement can be nested within another INCLUDE member, up to 15 levels deep.

45. A JCL has 2 steps. How to code the JCL such that if step1 abends, then step2 runs; otherwise, the job terminates after step1?

To achieve this behavior, you can code the COND=ONLY parameter in step2. This parameter specifies that step2 should execute only if any previous step, in this case, step1, has abended (terminated abnormally).

46. How do you handle and manage error conditions in JCL?

  • COND Parameter – Skips job steps based on return codes from previous steps.
    //STEP2 EXEC PGM=PROG2,COND=(4,LT,STEP1)
  • Using the IF/THEN/ELSE Statement (JCL IF Logic) – Allows conditional execution based on return codes.
    //STEPIF IF (STEP1.RC = 8) THEN
    //STEP2 EXEC PGM=PROG2
    //ENDIFST ENDIF
  • Using the ABEND Code Handling Mechanism - Capture system abends (Sxxx) and user abends (Uxxx) using tools like ABEND-AID or IBM Fault Analyzer.
  • Using System Return Codes (MAXCC, LASTCC) - IDCAMS Example:
    //STEP1 EXEC PGM=IDCAMS
    //SYSIN DD *
    DELETE MY.FILE
    IF LASTCC > 4 THEN
       SET MAXCC = 12
    /* 
  • Using JCL Dumps for Debugging -
    • SYSUDUMP – Provides register and storage dump.
    • SYSABEND – Gives detailed storage information.
    • SYSMDUMP – Produces a formatted dump for analysis.
  • Using JES Message Logs (SYSOUT) - Monitor job output logs (SYSOUT=*) for debugging errors.

47. How can you check if a file is empty using JCL?

You can check if a file is empty in JCL using the IDCAMS utility with the PRINT command and checking the return code (RC). If the file is empty, IDCAMS will return RC=4.

//CHKFILE JOB ...
//*
//CHECKFIL  EXEC PGM=IDCAMS
//SYSPRINT  DD  SYSOUT=*
//SYSIN     DD  *
   PRINT INFILE(YOUR.DATASET.NAME) COUNT(1)
/*

After execution, check the RC:

  • RC=0: File is not empty.
  • RC=4: File is empty.

48. How many extents are possible for a sequential file? For a VSAM file?

An extent is a continuous space on a disk storage unit allocated for a dataset. The maximum number of extents allowed are:

  • Sequential file: Up to 16 extents on a single volume.
  • VSAM file: Up to 123 extents on a single volume.

49. Explain symbolic parameters and their uses in JCL.

A symbolic parameter is a placeholder variable in JCL, defined using & and assigned a value at execution time. It makes JCL flexible, reusable, and easy to maintain.

  • Defining Symbolic Parameters in a PROC:
    //MYPROC PROC INFILE=&DSN
    //STEP1  EXEC PGM=MYPROG
    //IN1    DD DSN=&DSN,DISP=SHR
  • Assigning Values in JCL:
    //JOBNAME JOB ...
    //STEP1   EXEC MYPROC,DSN=MY.INPUT.FILE

50. What is the purpose of the MSGCLASS parameter in JCL and how might you use it?

The MSGCLASS parameter in JCL controls where system-generated job output messages (JES messages) are directed. Defines the output class for job logs (e.g., system messages, errors, execution details). Determines whether job logs are printed, saved, or sent to a spool for later review.

Example -

//JOBNAME JOB 'TEST JOB',MSGCLASS=A
  • MSGCLASS=A → Sends job logs to the output class A (defined in JES).
  • Different classes (A-Z, 0-9) can be configured for printing, archiving, or viewing in SDSF.