Post By: Hanan Mannan
Contact Number: Pak (+92)-321-59-95-634
-------------------------------------------------------
Contact Number: Pak (+92)-321-59-95-634
-------------------------------------------------------
JCL Interview Questions
1) There is a concatenated input DD name with 3 datasets. How to override only one dataset in those 3 datasets?
Specify DD DUMMY in the overriding JCL for the ones, which are not overridden.
//STEP1.IN1 DD DUMMY // DD DSN=MYDATA.URMI.IN2,DISP=SHR // DD DUMMY
2) 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?
Step1 input: (0) Step1 output: (+1) Step2 input: (+1) Step2 output: (+2)
3) How can you check if a file is empty using JCL?
When the file is used as input in IDCAMS, job completes with a warning (return code 4) if the file is empty.
4) A JCL has 4 steps and job abends. How to restart the job and run only step 2?
Specify RESTART=STEP2 in JOB statement. And include IF-THEN-ELSE construct as below:
//URMIIF JOB 1,CLASS=6,MSGCLASS=0,NOTIFY=&SYSUID,RESTART=STEP2 //* //STEP1 EXEC //STEP2 EXEC //IF1 IF (STEP2.RC = 0 & STEP2.RC <> 0) THEN //STEP3 EXEC //STEP4 EXEC // ENDIF
Another solution is to use COND=((0,EQ,STEP2),(0,NE,STEP2)) for step3 and step4.
5) What are the ways of passing data to a COBOL program from JCL?
Data can be passed to a COBOL program through files, PARM parameter and SYSIN DD statement.
6) How can the same PROC be re-used and called by many JOBs?
The varying portion of the JCL can be specified using symbolic parameters in the JOB and the static parts can be specified in the PROC. For example, if the file name changes for every JOB that uses the PROC, then the varying portion of the file name can be coded in JCL using symbolic parameter.
//IN1 DD DSN=&ID.URMI.IN1,DISP=SHR //*Coded in PROC ID=MYDATA1 is coded in JOB1, ID=MYDATA2 is coded in JOB2 and so on
7) How do you create a dataset in a JCL with the same file organisation as that of another existing dataset?
Use IEBGENER and pass existing file in SYSUT1. Pass new file in SYSUT2 and mention DCB=*.SYSUT1 to get the same DCB as that of SYSUT1 dataset. Refer to Basic Sort Tricks chapter for IEBGENER example.
8) How do you access an uncataloged dataset in a JCL?
By using the UNIT and VOL serial parameters in the dataset DD statement.
9) What are the statements that are not valid to be included in an INCLUDE statement?
Dummy DD statements, data card specifications, PROCs, JOB, PROC statements cannot be coded within an INCLUDE member. An INLCUDE statement can be coded within an INCLUDE member and further nesting can be done up to 15 levels.
10) A JCL has 2 steps. How to code the JCL such that if step1 abends, then step2 runs. Else, job terminates with step1?
Code COND=ONLY in STEP2
11) How to do automated RESTART when a job abends?
Using RD parameter in JOB/EXEC statement. The abend codes for which RESTART need to be performed can be mentioned in the SCHEDxx member of the IBM system parmlib library.
12) A JCL has 10 steps. How to run step3 and step7 (only) without using COND parameter or IF-THEN-ELSE?
//STEP001 EXEC PGM=IEBEDIT //SYSUT1 DD DSN=MYDATA.URMI.JOBS(INPUTJOB),DISP=SHR //SYSUT2 DD SYSOUT=(*,INTRDR) //SYSPRINT DD SYSOUT=* //SYSIN DD * EDIT TYPE=INCLUDE,STEPNAME=(STEP3,STEP7) /*
Using IEBEDIT in a JCL, selected steps of another JCL can be run. In the above JCL, the input JCL with 10 steps is present in MYDATA.URMI.JOBS(INPUTJOB). STEP3 and STEP7 is specified in SYSIN of IEBEDIT, so that those two steps are run.
13) When does a dataset go uncataloged?
When it is defined with DISP=(NEW,KEEP) at the time of creation.
In case of a GDG, least recent generation is uncataloged if the GDG base had been defined with NOEMPTY parameter when the LIMIT is reached. All generations are uncataloged when coded with EMPTY.
14) How can a GDG base be created in a JCL. What is the difference between EMPTY and SCRATCH parameter while defining/altering GDG base?
GDG base can be created using IDCAMS utility. EMPTY uncataloges all the generations when the LIMIT is reached. SCRATCH physically deletes the generation, when it is uncataloged. (LIMIT specifies the maximum number of versions that the GDG base can hold).
15) A dataset contains 2500 records. How can the last 1500 records copied to an output file?
//JSTEP020 EXEC PGM=ICETOOL //TOOLMSG DD SYSOUT=* //DFSMSG DD SYSOUT=* //IN1 DD DSN=MYDATA.URMI.SKIPREC,DISP=SHR //OUT1 DD SYSOUT=* //TOOLIN DD * COPY FROM(IN1) TO(OUT1) USING(CTL1) /* //CTL1CNTL DD * SORT FIELDS = COPY SKIPREC = 1000 /*
In the SORT/ICETOOL program, SKIPREC = n can be used, which skips the first n records and then copies the rest to the output file.
16) How can a file of 3n records be split into 3 files each containing n records?
//URMISPLT EXEC PGM=SORT //SORTIN DD DSN=MYDATA.URMI.FILEIN,DISP=SHR //SORTOF01 DD DSN=MYDATA.URMI.FILEOUT1, // DISP=(NEW,CATLG,DELETE), // RECFM=FB,LRECL=50 //SORTOF02 DD DSN=MYDATA.URMI.FILEOUT2, // DISP=(NEW,CATLG,DELETE), // RECFM=FB,LRECL=50 //SORTOF03 DD DSN=MYDATA.URMI.FILEOUT3, // DISP=(NEW,CATLG,DELETE), // RECFM=FB,LRECL=50 //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSUDUMP DD SYSOUT=* //SYSIN DD * SORT FIELDS=COPY OUTFIL FILES=01,ENDREC=100 //*assuming input file has 300 records. OUTFIL FILES=02,STARTREC=101,ENDREC=200 OUTFIL FILES=03,STARTREC=201 //*
STARTREC and ENDREC restricts the READ from the input file on the specified record number.
17) When can a job time-out occur? How to overcome that?
A job time-out error can occur when the program takes more time than the time limit for the specified class. This is called a S322 abend. This error is encountered when there are some looping errors in the program and it does not reach completion.
If the data processed in the program is genuinely huge and needs more time than the class limit, then the TIME parameter can be coded as TIME=1440 to get infinite time until job completion.
18) In a JCL, a large volume dataset is loaded to a table using BMCLOAD in STEP1 and an image copy of the loaded table is taken using BMCCOPY in step2. Step2 abends because the image copy dataset cannot hold the volume of the table. How can this be rectified?
The SPACE parameter of the image copy dataset can be increased based on the volume of the table and the job can be restarted from step2.
19) If the submitter of a job wants to inform another user about the job completion, how can it be done?
NOTIFY=userid of the person (not the submitter) can be specified in the JOB statement so that the user gets a notification with the return code upon job completion. But the job log is present in the spool under the submitter's userid only.
20) How can a FB file converted to VB file using SORT program?
FTOV option in SORT helps in converting FB to VB file.
//URMIFTOV EXEC PGM=SORT //SORTIN DD * 123******* 4560000000 123****123 789 //SORTOF01 DD DSN=MYDATA.URMI.FILEOUT1, // DISP=(NEW,CATLG,DELETE), // RECFM=VB,LRECL=54 //SORTOF02 DD DSN=MYDATA.URMI.FILEOUT2, // DISP=(NEW,CATLG,DELETE), // RECFM=VB,LRECL=54 //SORTOF03 DD DSN=MYDATA.URMI.FILEOUT3, // DISP=(NEW,CATLG,DELETE), // RECFM=VB,LRECL=54 //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSUDUMP DD SYSOUT=* //SYSIN DD * SORT FIELDS=COPY OUTFIL FNAMES=SORTOF01,FTOV,VLTRIM=C'*' //*removes trailing '*' OUTFIL FNAMES=SORTOF02,FTOV,VLTRIM=X'40'//*removes trailing space OUTFIL FNAMES=SORTOF03,FTOV,VLTRIM=X'00'//*removes trailing zeros //*
The output will be:
SORTOF01: 123 //*Trailing '*' removed 4560000000 123****123 789 SORTOF02: 123******* //*Trailing spaces removed 4560000000 123****123 789 SORTOF03: 123******* 4560 //*Trailing zeroes removed 123****123 789
0 comments:
Post a Comment