JCL Realtime (Scenario based) Interview Questions (21 - 30)

21. Write a JCL to execute a program with a specific region size.

To specify a region size for a program in JCL, use the REGION parameter in the EXEC statement.

//MYJOB JOB 'TEST',CLASS=A,MSGCLASS=A
//STEP1   EXEC PGM=MYPROG,REGION=4M

REGION=4M: Specifies that the job has a region size of 4 megabytes.

22. Explain the difference between a cataloged and uncataloged dataset in JCL.

A cataloged dataset is registered in the system catalog, making it easily accessible without needing explicit path information. An uncataloged dataset, on the other hand, is not registered in the system catalog and requires explicit path information for access.

23. Write a JCL to delete a dataset using the IDCAMS utility.

To delete a dataset using the IDCAMS utility, you would use the following JCL snippet:

//DELETEFL JOB (123),'MTH',CLASS=A,MSGCLASS=A,
//             MSGLEVEL=(1,1),NOTIFY=&SYSUID 
//******************************************
//* DELETING ESDS
//******************************************
//STEP01   EXEC PGM=IDCAMS
//SYSPRINT DD   SYSOUT=*
//SYSIN    DD   *
      DELETE 'MATEPK.TEST.ESDS'
/*

24. What is the significance of the ADDRSPC parameter in the EXEC statement?

The ADDRSPC parameter in the EXEC statement in JCL specifies whether a job step should use virtual or real storage. The ADDRSPC parameter is used to indicate the type of storage required for the job step's execution. ADDRSPC={REAL|VIRT}. REAL specifies the physical memory. VIRT specifies a combination of real memory and disk space

25. What happens when COND is coded in JOB statement and when COND is coded inside EXEC statement?

COND parameter at the step level is applied for the specific step. COND parameter at job level is applied to the remaining steps which doesn't have COND parameter.

26. There is a concatenated input DD name with 3 datasets. How to override only one dataset in those 3 datasets?

If a DD statement contains three concatenated datasets, you can override only one of them using a JCL override in a PROC or in a calling JCL.

Overriding in a JCL with PROC -

//MYPROC PROC ...
//STEP1 EXEC PGM=MYPROG
//INFILE DD DSN=DATASET1,DISP=SHR
//       DD DSN=DATASET2,DISP=SHR
//       DD DSN=DATASET3,DISP=SHR

If this JCL is inside a PROC, override only DATASET2 in the calling JCL:

//MYPROC PROC ...
//STEP1 EXEC PGM=MYPROG
//INFILE DD DSN=DATASET1,DISP=SHR
//       DD DSN=NEW.DATASET2,DISP=SHR
//       DD DSN=DATASET3,DISP=SHR

Overriding in a JCL without PROC -

If not using a PROC, you need to redefine the entire concatenation, replacing only the dataset you want to override:

//MYJOB JOB ...
//STEP1 EXEC PGM=MYPROG
//INFILE DD DSN=DATASET1,DISP=SHR
//       DD DSN=NEW.DATASET2,DISP=SHR
//       DD DSN=DATASET3,DISP=SHR

27. Current version of a GDG is used as input in step1 of a job and a new version is created as output. The output of step1 is used in step2 and the next version is created as output in step2. How do you reference each GDG version in each step?

In JCL, relative generation numbers are used to handle input and output GDG versions across multiple steps.

  • STEP1: - Reads the current version (GDG(0)) and writes a new version (GDG(+1)).
  • STEP2: - Uses GDG(+1) as input (explicit reference to the new version from STEP1) and creates GDG(+2) as output (next version).

JCL Implementation:

//STEP1 EXEC PGM=MYPROG
//INPUT  DD DSN=MY.GDG.BASE(0),DISP=SHR
//OUTPUT DD DSN=MY.GDG.BASE(+1),
//            DISP=(NEW,CATLG,DELETE),
//            SPACE=(CYL,5),DCB=(RECFM=FB,LRECL=80)

//STEP2 EXEC PGM=MYPROG2
//INPUT  DD DSN=MY.GDG.BASE(+1),DISP=OLD 
//OUTPUT DD DSN=MY.GDG.BASE(+2),
//            DISP=(NEW,CATLG,DELETE),
//            SPACE=(CYL,5),DCB=(RECFM=FB,LRECL=80)

28. A JCL has 4 steps and job abends. How to restart the job and run only step 2?

To restart the job from STEP2 and run only that step, use the RESTART parameter and COND=EVEN or COND=ONLY as needed.

  • STEP1: - Using RESTART in JOB Statement
    //MYJOB JOB ...,RESTART=STEP2
  • STEP2: - Modify the JCL to restart from STEP2 and ensure only STEP2 runs by skipping later steps:
    //MYJOB JOB ...,RESTART=STEP2
    //STEP3 EXEC PGM=PROG3,COND=(0,LE)
    //STEP4 EXEC PGM=PROG4,COND=(0,LE)

COND=(0,LE) ensures STEP3 and STEP4 are bypassed when restarting from STEP2.

29. What are the ways of passing data to a COBOL program from JCL?

  • Using the PARM Parameter (For Small Data - Max 100 Characters) - Passes data via the PARM keyword in the EXEC statement.
  • Using SYSIN - Passes data through a SYSIN DD statement.
  • Using a File - JCL defines a dataset and COBOL reads it.

30. How can the same PROC be re-used and called by many JOBs?

A PROC (Procedure) can be reused and called by multiple JOBs by storing it in a PROCLIB (Procedure Library) and referencing it in different JCL JOBs.

  • STEP1: - Store the PROC in a Procedure Library (e.g., SYS1.PROCLIB or a MTH.PROCLIB):
    //MYPROC PROC
    //STEP1 EXEC PGM=MYPROG
    //INFILE DD DSN=&DSN,DISP=SHR
  • STEP2: - Call the PROC from Different Jobs Using EXEC PROC:
    //JOB1 JOB ...
    //LIB  JCLLIB ORDER=(MTH.PROCLIB)
    //STEP1 EXEC MYPROC,DSN=INPUT.FILE1