0% found this document useful (0 votes)
4 views40 pages

Mainframe Interview Questions

The document provides a comprehensive overview of COBOL programming, detailing its divisions, data types, and key concepts such as the INITIALIZE verb, LINKAGE SECTION, and level numbers. It explains the differences between various COBOL constructs like SEARCH and SEARCH ALL, as well as data handling techniques including REDEFINES and justification. Additionally, it covers error handling, sorting, and the use of the EVALUATE statement, emphasizing the importance of proper data management and program structure.

Uploaded by

abhishek.p6296
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views40 pages

Mainframe Interview Questions

The document provides a comprehensive overview of COBOL programming, detailing its divisions, data types, and key concepts such as the INITIALIZE verb, LINKAGE SECTION, and level numbers. It explains the differences between various COBOL constructs like SEARCH and SEARCH ALL, as well as data handling techniques including REDEFINES and justification. Additionally, it covers error handling, sorting, and the use of the EVALUATE statement, emphasizing the importance of proper data management and program structure.

Uploaded by

abhishek.p6296
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

COBOL

1. Name the divisions in a COBOL program.

IDENTIFICATION DIVISION – PROGRAM-ID {Mandatory para}

ENVIRONMENT DIVISION

CONFIGURATION SECTION –

Source computer (system used to compile pgm)

Object computer (system used to execute pgm)

INPUT-OUTPUT SECTION –

FILE-CONTROL (external datasets used in pgm)

I-O CONTROL (info of files used in pgm)

DATA DIVISION

FILE SECTION – Define record structure of files

WORKING-STORAGE SECTION – Temporary variables used in pgm

LOCAL-STORAGE SECTION – Temporary variables

LINKAGE SECTION – Data names received from external programs or parms

PROCEDURE DIVISION

Contains logic and STOP RUN for calling pgms and EXIT PROGRAM for called pgms

GO BACK – satisfies same purpose, returns control to called pgms or system

Area: Columns

1-6 = Sequence numbers

7 = comment or continuation character

8-11 = Area A – Divisions, sections, paras, FD entries, 01 LEVEL number items

12-72 = Area B
2. What are the different data types available in COBOL?

Alpha-numeric (X) –> Max 160, alphabetic (A) –> A-Z and numeric (9) -> Max 18.

3. What does the INITIALIZE verb do? Alphabetic, Alphanumeric fields & alphanumeric
edited items are set to SPACES. Numeric, Numeric edited items set to ZERO. Group
items advantage.

4. Can we INTIALIZE FILLER? – No, we can’t

5. Importance of LINKAGE-SECTION? Used in sub programs to capture data from calling


pgms. Also, to capture data from JCL through PARM. S9(4) COMP is additionally required
along with these fields to store the length of data passed from JCL.

05 L-PARM-LEN PIC S9(n) USAGE IS COMP.

If 'n' = 1 to 4, it takes 2 bytes.


If 'n' = 5 to 9, it takes 4 bytes.
If 'n' = 10 to 18, it takes 8 bytes.

6. About Level numbers?

General Purpose: 01 to 49 can be used. Group Items – Won’t have a PIC clause and can
be used from 01 to 48. Elementary data items – will be under a group item with PIC clause
02 to 49.

Special Purpose:

66 Level - RENAMES – Regrouping of Elementary data items {Logical group from group of
elements} – 66 Level number – No PIC clause & Cannot rename 01,77,88 or other 66 level
items & also elementary items with OCCURS clause

01 A.
05 ITEM1 PIC X (5).
05 ITEM2 PIC X (5).
05 ITEM3 PIC X (5).
05 ITEM4 PIC X (5).
66 B RENAMES ITEM2 THRU ITEM4.
77 Level – Independent items (Can’t be subdivided further) – must be declared in AREA A.
88 Level – sub-ordinate to other data items (01 - 49)– Requires NO memory. I want to you
process records having Jan Month, how can we do this in COBOL? Using Condition names
01 EMP-SALARY-LEVELS PIC 9 (09).
88 FRESHER VALUE 50 TO 100.
88 SENIOR VALUE 150 TO 300.
88 MANAGER VALUE 400 TO 500.
88 PRESIDENT VALUE 600 TO 900.

7. What does the IS NUMERIC clause establish? IS NUMERIC can be used on


alphanumeric items, signed numeric & packed decimal items and unsigned numeric &
packed decimal items. IS NUMERIC returns TRUE if the item only consists of 0-9. However,
if the item being tested is a signed item, then it may contain 0-9, + and –.

8. How do you define a table/array in COBOL?

01 ARRAYS.

05 ARRAY1 PIC X(9) OCCURS 10 TIMES.

05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX.

9. Can the OCCURS clause be at the 01 level? No.

[Link] is the difference between index and subscript?

Subscript Index
No of occurrences of an array. No of displacement positions of an array.
It will be declared in WORKING-STORAGE Index need not be declared in WORKING-
SECTION. STORAGE SECTION.
Slow in access. Index is faster.
Initialized by using MOVE statement. Index is initialized by using SET operator.
Incremented by using ADD operator. Incremented by SET UP BY operator.
No need to declare INDEXED BY clause. INDEXED BY clause is used to declare along with
occurs.
Subscript refers to the array occurrence while index is the displacement (in no of bytes) from
the beginning of the array. An index can only be modified using PERFORM, SEARCH &
SET. Need to have index for a table in order to use SEARCH, SEARCH ALL.

11. What is the difference between SEARCH and SEARCH ALL?

IDENTIFICATION DIVISION.
PROGRAM-ID. PERFTIMI.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 SECTION.
02 STUDENT.
03 SUBJECT PIC 9(3) OCCURS 6 TIMES INDEXED BY SEQ.
PROCEDURE DIVISION.
PERFORM SEQ FROM 1 BY 1 UNTIL SEQ > 6
ACCEPT MARKS[SEQ]
END-PERFORM.

SET SEQ TO 1.

SEARCH STUDENT VARYING SEQ


AT END DISPLAY ‘STUDENT PASSED’
WHEN SUBJECT[SEQ] < 35
DISPLAY ‘STUDENT FAILED’
END-SEARCH.

SEARCH – is a serial search. SEARCH ALL – is a binary search & the table must be sorted
(ASCENDING/DESCENDING KEY clause to be used & data loaded in this order) before
using SEARCH ALL.

[Link] should be the sorting order for SEARCH ALL? It can be either ASCENDING or
DESCENDING. ASCENDING is default. If you want the search to be done on an array
sorted in descending order, then while defining the array, you should give DESCENDING
KEY clause. (You must load the table in the specified order).

[Link] is binary search? Search on a sorted array. Compare the item to be searched with
the item at the centre. If it matches, fine else repeat the process with the left half or the right
half depending on where the item lies.

[Link] program has an array defined to have 10 items. Due to a bug, I find that even if the
program accesses the 11th item in this array, the program does not abend. What is wrong
with it? Must use compiler option SSRANGE if you want array bounds checking. Default is
NOSSRANGE. – It is COBOL COMPILER option & specified in parm of IGYCRCTL

[Link] do you sort in a COBOL program? Give sort file definition, sort statement syntax
and meaning.

Syntax:

SORT file-1 ON ASCENDING/DESCENDING KEY

USING file-2 GIVING file-3.


Steps: SORT Verb

1. Opens file1 (workfile) in I-O mode, file2 in INPUT mode and file3 in OUTPUT mode.

2. Copies the records from file 1 to file2 and performs SORT

3. Copies the sorted records to file3 and deletes workfile. Closes file2 and file3.

USING can be substituted by INPUT PROCEDURE IS para-1 THRU para-2 GIVING can be
substituted by OUTPUT PROCEDURE IS para-1 THRU para-2.

file-1 is the sort workfile and must be described using SD entry in FILE SECTION.

file-2 is the input file for the SORT and must be described using an FD entry in FILE
SECTION and SELECT clause in FILE CONTROL.

file-3 is the outfile from the SORT and must be described using an FD entry in FILE
SECTION and SELECT clause in FILE CONTROL. file-1, file-2 & file-3 should not be
opened explicitly.

INPUT PROCEDURE is executed before the sort and records must be RELEASED to the
sort work file from the input procedure. OUTPUT PROCEDURE is executed after all records
have been sorted. Records from the sort work file must be RETURNed one at a time to the
output procedure.

MERGE

MERGE work-file(file1) on ASCENDING KEY rec-key1

USING file2, file3 giving file4 – Same steps as above SORT verb

Work file is file1, input files – file2, file3, output file – file4

[Link] do you define a sort file in JCL that runs the COBOL program? Use the
SORTWK01, SORTWK02….. dd names in the step. Number of sort datasets depends on
the volume of data being sorted, but a minimum of 3 is required.

17. What are the restrictions with in COBOL SORT? Restrictions – Cannot massage
records, cannot select records to be sorted.
[Link] is the difference between performing a SECTION and a PARAGRAPH? Performing
a SECTION will cause all the paragraphs that are part of the section, to be performed.
Performing a PARAGRAPH will cause only that paragraph to be performed.

[Link] is the use of EVALUATE statement? Evaluate is like a case statement and can be
used to replace nested Ifs. The difference between EVALUATE and case is that no ‘break’ is
required for EVALUATE i.e. control comes out of the EVALUATE as soon as one match is
made.

[Link] are the different forms of EVALUATE statement?

Simple EVALUATE –

EVALUATE ws-var

WHEN 01 – do this

WHEN 02 – do this

WHEN OTHER

END-EVAUATE

EVALUATE TRUE

WHEN ws-var = 10

WHEN ws-var = 15

WHEN OTHER

END-EVALUATE.

EVALUATE THRU

EVALUATE ws-var

WHEN 50 thru 100

WHEN 150 thru 190


WHEN OTHER

END-EVALUATE.

EVALUATE MULTIPLE WHENS

EVALUATE MULTIPLE CONDITIONS

EVALUATE TRUE ALSO TRUE

WHEN I = 0 ALSO A = 0

WHEN B = 9 ALSO A = 4

END-EVALUATE.

[Link] do you come out of an EVALUATE statement? After the execution of one of the
when clauses, the control is automatically passed on to the next sentence after the
EVALUATE statement. There is no need of any extra code.

[Link] an EVALUATE statement, can I give a complex condition on a when clause? Yes.

[Link] is a scope terminator? Give examples. Scope terminator is used to mark the end of
a verb e.g. EVALUATE, ENDEVALUATE; IF, END-IF.

[Link] do you do in-line PERFORM? PERFORM … <sentences> END PERFORM

[Link] would you use in-line perform? When the body of the perform will not be used in
other paragraphs. If the body of the perform is a generic type of code (used from various
other places in the program), it would be better to put the code in a separate para and use
PERFORM Para name rather than in-line perform.

[Link] is the difference between CONTINUE & NEXT SENTENCE? CONTINUE is like a
null statement (do nothing) and transfers control to next COBOL verb, while NEXT
SENTENCE transfers control to the next sentence (!!) (A sentence is terminated by a period)

[Link] does EXIT do? Does nothing! If used, must be the only sentence within a
paragraph in OSVS COBOL. In COBOL II you can have other statements along with EXIT.
[Link] I redefine an X (100) field with a field of X (200)? Yes. Redefines just causes both
fields to start at the same location. For example:

01 WS-TOP PIC X (1)

01 WS-TOP-RED REDEFINES WS-TOP PIC X (2).

If you MOVE ‘12’ to WS-TOP-RED, DISPLAY WS-TOP will show 1 while DISPLAY WS-
TOP-RED will show 12. This works only if the level number is 01. If the respective level
numbers were saying 05, then you will get a severe error in compilation.

[Link] I redefine an X (200) field with a field of X (100)? Yes.

31. Redefines? REDEFINES clause allows to use same memory location with different
name. Already REDEFINED can’t be REDEFINED again. Can be used with level numbers
01 to 49 & 77. 66 & 88 can’t be REDEFINED. Only applicable on same group level. Size
may or may not be same as the variable which u want to REDEFINE. REDEFINED can be
done by changing the USAGE clause as well. If any one of the data is modified then
automatically the other one will get modified as they use same memory location.

31. Data Justifications? Justifications come if data size of input variable is larger or smaller
than output variable.

Numeric Justification: Right Justified (Right Most byte to left)

Ex: 9374896296 is X (8) & moving it is X (4) THEN output will have 6296

6296 is in X (4) and moving to X (8) THEN output will have 00006296

Alphanumeric and Alphabetic: Left Justified (Left most byte to Right)

Ex: ABHISHEK is X (8) & moving it is X (4) THEN output will have ABHI

ABHI is in X (4) and moving to X (8) THEN output will have ‘ABHI ‘

[Link] do you do to resolve SOC-7 error? Basically, you need to correct the offending
data. Many times, the reason for SOC7 is an un-initialized numeric item. Examine that
possibility first. Many installations provide you a dump for run time abends (it can be
generated also by calling some subroutines or OS services thru assembly language). These
dumps provide the offset of the last instruction at which the abend occurred. Examine the
compilation output XREF listing to get the verb and the line number of the source code at
this offset. Then you can look at the source code to find the bug. To get capture the runtime
dumps, you will have to define some datasets (SYSABOUT etc) in the JCL. If none of these
are helpful, use judgement and DISPLAY to localize the source of error. Some installation
might have batch program debugging tools. Use them.

32. USAGE clause/Computations? To reduce storage space and indirectly increases


efficiency of the program & specifies how the data item stored internally. Every variable
declared in COBOL have USAGE clause and if not specified then ‘USAGE IS DISPLAY’.

COMP/COMPUTATION: Data in COMP is stored in binary format

Picture Number of Bytes


S9 to S9(4) 2
S9(5) to S9(9) 4
S9(9) to S9(18) 8
COMP-1: Applicable to Single precision floating point - Max 4 bytes (32 bits)

It will store the data in the form of Mantissa and Exponent.

Ex: 9.999 value needs to be stored in COMP-1 then it will be stored like 9999 * 10^-3

10^-3 is stored in left most 8 bits and 9999 is stored in remaining 24 bits.

COMP-2: Applicable to Double precision floating point (stored in Hexa decimal form)

It will store the data in the form of Mantissa and Exponent.

Ex: 9.999 value needs to be stored in COMP-2 then it will be stored like 9999 * 10^-3

10^-3 is stored in left most 12 bits and 9999 is stored in remaining 52 bits.

COMP-3: Data will be stored in Packed Decimal format – 2 digits in each byte. Amount, QTY
fields.

33. How is sign stored in Packed Decimal fields and Zoned Decimal fields?
Packed Decimal fields: Sign is stored as a hex value in the last nibble (4 bits) of the storage.
Zoned Decimal fields: As a default, sign is over punched with the numeric value stored in the
last byte.

[Link] is sign stored in a comp-3 field? – GS

It is stored in the last nibble. For example, if your number is +100, it stores hex 0C in the last
byte, hex 1C if your number is 101, hex 2C if your number is 102, hex 1D if the number is -
101, hex 2D if the number is -102 etc…

34. How is sign stored in a COMP field? – GS

In the most significant bit. Bit is on if -ve, off if +ve.

[Link] is the difference between COMP & COMP-3 ?

COMP is a binary storage format while COMP-3 is packed decimal format.

[Link] is COMP-1? COMP-2?

COMP-1 – Single precision floating point. Uses 4 bytes. COMP-2 – Double precision
floating point. Uses 8 bytes.

[Link] do you define a variable of COMP-1? COMP-2?

No picture clause to be given. Example 01 WS-VAR USAGE COMP-1.

[Link] many bytes does a S9(7) COMP-3 field occupy ?

Will take 4 bytes. Sign is stored as hex value in the last nibble. General formula is INT((n/2)
+ 1)), where n=7 in this example.

[Link] many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy ?

Will occupy 8 bytes (one extra byte for sign).

[Link] many bytes will a S9(8) COMP field occupy ?

4 bytes.
[Link] is the maximum value that can be stored in S9(8) COMP?

99999999

[Link] is COMP SYNC?

Causes the item to be aligned on natural boundaries. Can be SYNCHRONIZED LEFT or


RIGHT. For binary data items, the address resolution is faster if they are located at word
boundaries in the memory. For example, on main frame the memory word size is 4 bytes.
This means that each word will start from an address divisible by 4. If my first variable is
x(3) and next one is s9(4) comp, then if you do not specify the SYNC clause, S9(4) COMP
will start from byte 3 ( assuming that it starts from 0 ). If you specify SYNC, then the binary
data item will start from address 4. You might see some wastage of memory, but the access
to this computational field is faster.

Inspect verb is used to count or replace the characters in a string.

INSPECT WS-STRING TALLYING WS-CNT FOR CHARACTER

INSPECT WS-STRING TALLYING WS-CNT FOR ALL ‘A’

INSPECT WS-STRING REPLACING ALL ‘A’ BY ‘B’

STRING – ‘Delimited By’ clause is compulsory

ATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-STRING PIC A(30).
01 WS-STR1 PIC A(15) VALUE 'Tutorialspoint'.
01 WS-STR2 PIC A(7) VALUE 'Welcome'.
01 WS-STR3 PIC A(7) VALUE 'To AND'.
01 WS-COUNT PIC 99 VALUE 1.

PROCEDURE DIVISION.
STRING WS-STR2 DELIMITED BY SIZE
WS-STR3 DELIMITED BY SPACE
WS-STR1 DELIMITED BY SIZE
INTO WS-STRING
WITH POINTER WS-COUNT
ON OVERFLOW DISPLAY 'OVERFLOW!'
END-STRING.
WS-STRING : WelcomeToTutorialspoint
WS-COUNT : 25
UNSTRING – ‘Delimited by’ clause is compulsory

01 WS-STRING PIC A(30) VALUE 'WELCOME TO TUTORIALSPOINT'.


01 WS-STR1 PIC A(7).
01 WS-STR2 PIC A(2).
01 WS-STR3 PIC A(15).
01 WS-COUNT PIC 99 VALUE 1.

PROCEDURE DIVISION.
UNSTRING WS-STRING DELIMITED BY SPACE
INTO WS-STR1, WS-STR2, WS-STR3
END-UNSTRING.
WS-STR1 : WELCOME
WS-STR2 : TO
WS-STR3 : TUTORIALSPOINT

FILE ORGANIZATION: Indicates how records organized in file.

 Sequential file organization – Records stored & accessed in sequential order.


Flat files, QSAM file and NON-VSAM file – Records read TOP to BOTTOM but not
BOTTOM to TOP – Specific record reading or Deleting is not possible but can
UPDATE the record

SELECT file-name ASSIGN TO dd-name

ORGANIZATION IS SEQUENTIAL

 Indexed Sequential file organization – Records stored in sort order based on key
and can be accessed fast using key. Duplicate records not allowed. Specific record
reading and deleting is possible in indexed files. Indexed files are stored on DISK not
on tape – VSAM (KSDS)

SELECT file-name ASSIGN TO dd-name

ORGANIZATION IS INDEXED

 Relative file organization – Records stored based on Relative Record Number


(RRN) & RRN is not user defined but system defined. Whenever we delete any data
in RRN file then unused storage space is created.
SELECT file-name ASSIGN TO dd-name

ORGANIZATION IS RELATIVE

If ORGANIZATION is not mentioned – default is SEQUENTIAL

Now, how these organized records are accessed in a file?

Sequential – Records accessed in an order in which they are inserted. – PS,VSAM,Relative

SELECT file-name ASSIGN TO dd-name

ORGANIZATION IS SEQUENTIAL

ACCESS MODE IS SEQUENTIAL

SELECT file-name ASSIGN TO dd-name

ORGANIZATION IS INDEXED

ACCESS MODE IS SEQUENTIAL

RECORD KEY IS rec-key1

ALTERNATE RECORD KEY IS rec-key2

SELECT file-name ASSIGN TO dd-name

ORGANIZATION IS RELATIVE

ACCESS MODE IS SEQUENTIAL

RELATIVE KEY IS rec-key1

Random – Records accessed based on key – VSAM file + Relative files

SELECT file-name ASSIGN TO dd-name

ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM

RECORD KEY IS rec-key1

ALTERNATE RECORD KEY IS rec-key2

SELECT file-name ASSIGN TO dd-name

ORGANIZATION IS RELATIVE

ACCESS MODE IS RANDOM

RELATIVE KEY IS rec-key1

Dynamic – Records can be accessed both sequentially and randomly – VSAM

SELECT file-name ASSIGN TO dd-name

ORGANIZATION IS SEQUENTIAL

ACCESS MODE IS DYNAMIC

SELECT file-name ASSIGN TO dd-name

ORGANIZATION IS INDEXED

ACCESS MODE IS DYNAMIC

RECORD KEY IS rec-key1

ALTERNATE RECORD KEY IS rec-key2

SELECT file-name ASSIGN TO dd-name

ORGANIZATION IS RELATIVE

ACCESS MODE IS DYNAMIC


RELATIVE KEY IS rec-key1

[Link] do you reference the following file formats from COBOL programs:

Fixed Block File – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F,


BLOCK CONTAINS 0 .

Fixed Unblocked – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F,


do not use BLOCK CONTAINS

Variable Block File – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS


V, BLOCK CONTAINS 0. Do not code the 4 bytes for record length in FD ie JCL rec length
will be max rec length in pgm + 4

Variable Unblocked – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS


V, do not use BLOCK CONTAINS. Do not code 4 bytes for record length in FD ie JCL rec
length will be max rec length in

pgm + 4.

ESDS VSAM file – Use ORGANISATION IS SEQUENTIAL.

KSDS VSAM file – Use ORGANISATION IS INDEXED, RECORD KEY IS, ALTERNATE
RECORD KEY IS RRDS File – Use ORGANISATION IS RELATIVE, RELATIVE KEY IS
Printer File – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F,
BLOCK CONTAINS 0. (Use RECFM=FBA in JCL DCB).

[Link] are different file OPEN modes available in COBOL?

Open for INPUT, OUTPUT, I-O, EXTEND.

[Link] is the mode in which you will OPEN a file for writing? – GS

OUTPUT, EXTEND

[Link] the JCL, how do you define the files referred to in a subroutine?

Supply the DD cards just as you would for files referred to in the main program.
[Link] you REWRITE a record in an ESDS file? Can you DELETE a record from it?

Can rewrite(record length must be same), but not delete.

[Link] is file status 92? – GS

Logic error. e.g., a file is opened for input and an attempt is made to write to it.

[Link] is file status 39 ?

Mismatch in LRECL or BLOCKSIZE or RECFM between your COBOL pgm & the JCL (or the
dataset label). You will get file status 39 on an OPEN.

[Link] is Static, Dynamic linking?

In static linking, the called subroutine is link-edited into the calling program , while in dynamic
linking, the subroutine & the main program will exist as separate load modules. You choose
static/dynamic linking by choosing either the DYNAM or NODYNAM link edit option. (Even if
you choose NODYNAM, a CALL identifier (as opposed to a CALL literal), will translate to a
DYNAMIC call).

A statically called subroutine will not be in its initial state the next time it is called unless you
explicitly use INITIAL or you do a CANCEL. A dynamically called routine will always be in its
initial state.

[Link] is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY)? ( applicable to only


MVS/ESA Enterprise Server).

These are compile/link edit options.

AMODE – Addressing mode. RMODE – Residency mode. AMODE(24) – 24 bit addressing.


AMODE(31) – 31 bit addressing. AMODE(ANY) – Either 24 bit or 31 bit addressing
depending on RMODE. RMODE(24) – Resides in virtual storage below 16 Meg line. Use this
for 31 bit programs that call 24 bit programs. (OS/VS Cobol pgms use 24 bit addresses
only). RMODE(ANY) – Can reside above or below 16 Meg line.

[Link] compiler option would you use for dynamic linking?

DYNAM.
54. What if you forgot to close file in Cobol pgm? If any of the Opened file not closed, then the
execution completion of the program will close all the files which are used in the program.

STATIC Call:

1) Identified by Call literal.


Ex: CALL ‘PGM1’.
2) Default Compiler option is NODYNAM and so all the literal calls are considered as static calls
3) If the subprogram undergoes change, sub program and main program need to be recompiled
4) Sub modules are link edited with main module.
5) Size of load module will be large
6) Fast, Less flexible.
7) Sub-program will not be in initial stage the next time it is called unless you explicitly use
INITIAL or you do a CANCEL after each call.

DYNAMIC CALL
1) Identified by Call variable and the variable should be populated at run time.
01 WS-PGM PIC X(08).
Move ‘PGM1’ to WS-PGM
CALL WS-PGM

ON SIZE ERROR – To avoid data truncations if destination field is small.

COMPUTE A = B + C ON SIZE ERROR MOVE ZEROES TO A.

Ex: If Sometimes we need to divide something by 0 , then ON SIZE ERROR is used to avoid
SOCB abend
Common Abends (Mainframe Top Interview Questions/Mainframe Refresher/Mainframe FAQ)

1. s322 : timed out, try changing job class

2. s806 : load module not found. Check library specified in joblib

3. s913 : Insufficient authority. Check if you have required access to dataset

4. s878 : region size is not enough. Increase the value you have specified in REGION parameter
of JOB statement or in EXEC step.

5. s522: job cancelled by either user or operator.

6. s0c4: storage related problem. Check your linkage section, table definition, and FD section.

7. JCL error: file attributes doesn’t match; I have given RECFM=VB, RECLEN is same as that
specified in FD section. Why do I get this error? For variable record format files you should add 4
bytes to record length in DCB.

8. s0c7 : Invalid character in COMP/COMP-3 numeric field – check all COMP/COM-3 numeric
fields and arithmetic operations.

9. s013 – A file open error.

10. S722 – The Sysout or spool is full. You program is writing too many things to Sysout.
Increase job’s sysout limit by specifying ‘LINES=(150,WARNING)’ option in job statement and
then retry. This will increase your sysout limit to ‘150’ thousand lines.

MORGAN STANLEY 1st round

1)How do you compile a PL1 program?

2)What is an index in db2 and types of indexes?

3)In how many ways you can provide physical order of data?

4)What is deadlock?How the job will determine a deadlock and how do you
come out of it?
5)what is isolation level in DB2 and its types?

6)Write a query to display deptname and total number of employees in dept.

Dept table has dept name and [Link] table hasemployee id,name
and dept id?

How to handle in case a dept has zero employees?

7)What are joins and its types?

8)What is pseudo conversation in db2?

9)What is time parm in JCL? If job has time parm as 10 and three steps in it
has 5 each what will happen in this scenario?

10)Difference between XCTL,LINK and CALL used in CICS?

11)How will you remove duplicate rows in a file using SORT?

COBOL Pgm Compilation

Scenarios based COBOL interview questions


File Handling
1. Explain how files are handled in COBOL
program?
Files must be declared in in INPUT-OUTPUT SECTION (In ENVOIRNMENT DIVISION) under
FILE [Link] file name is assgined using SELECT clause to file. Also organization
(Whether indexed, sequential) and access mode (Sequential, random, dynamic) specified
here.

Then in FILE SECTION of DATA DIVISION, FD file descriptor is specified for the file where
record length , type of record (FB,VB) is specified along with record layout.

Then in prodcedure division file is opened as input,input-output,output mode.

records can be read using READ and can be written using WRITE/REWRITE statement.

Files can be closed using CLOSE statment in PROCEDURE DIVISION.

2. A MASTER-FILE has been opened in I-O


[Link] are the records in the file.
CAPGEMINI, PUNE
ACCENTURE,PUNE
INFOSYS,PUNE
COGNIZAT,PUNE.
And following COBOL statements are
executed in procedure division.
READ MASTER-FILE
READ MASTER-FILE
MOVE 'WIPRO,PUNE' TO MASTER-REC
WRITE MASTER-FILE FROM MASTER-REC.
Then what will be the contents of the file?
Since MASTER-FILE has been opened in I-O mode and WRITE statement is
trying to write in the same file, we will get invalid file status and no WRITE
operations will be performed.
Files which are delcared as I-O, only REWRITE statment can write the
records.
Hence contenets of the file will be same.
3. A MASTER-FILE has been opened in I-O
[Link] are the records in the file.

CAPGEMINI, PUNE
ACCENTURE,PUNE
INFOSYS,PUNE
COGNIZAT,PUNE.

And following COBOL statements are executed in


procedure division.

READ MASTER-FILE
READ MASTER-FILE
MOVE 'WIPRO,PUNE' TO MASTER-REC
REWRITE MASTER-FILE FROM MASTER-REC.
REWRITE MASTER-FILE FROM MASTER-REC.

Then what will be the contents of the file?


After execution of above statements of contents of the file will be

CAPGEMINI, PUNE

WIPRO,PUNE
INFOSYS,PUNE
COGNIZAT,PUNE.

File has been opened in input output mode. And first two records are read.
After that pointer now points to the second record in the file.
Now if REWRITE operation is performed, pointer will point to the second
record and second record will be overwritten. After rewrite, pointer will
still point to the second record in the file and same record will be
overwritten.

4. Program A has opened a file in output mode.


Program A calls Program B. Since file has already
opened in Program A, can program B directly
write into that file?
If program B has to write into the files, it cannot directly write into the file.

In both Programs Prog A and Prog B, file should be defined as external in FD. Also in both
the programs, file should be defined in FILE CONTROL using SELECT clause.
PROG A opens a file and calls prog B. Since file is already opened in PROG A, no open
statement required in PROG B.
And Then Prog B can write into the file.

5. If records needs to be deleted from a ps


file, Which one of the following verbs can
be used?

DELETE
ERASE
None of the above verbs can be used to delete the record from the PS file.

6. Can 88 levels be defined in 01 level


under FD?88 Levels can be defined under 01 - file layout under FD.
7. In a physically sequential file, after
reading 100 records , if again first records
needs to be read, then which one of the
following needs to be done?
A. Address of the first record from a file
needs to be stored into pointer using
ADDRESS OF keyword.
After reading 100 records, point to the
address stored into pointer using SET verb.
In this way records can be read from the
start again.
B. Close the file, OPEN it again and read it
from the start.
COBOL does not support address handling for the files. so first option is not possible.
Second option is easy. Since it is sequential file and records need to be read sequentially,
closing the file, oepning it and reading the records from the start is the only option
available.

8. Can COPY statement is used to copy all


the content of one file to another file?
COPY statement cannot be used for file handling. If all the conetnts from one file needs
to be copied to another file, the source file needs to be opened in INPUT mode and target
file needs to be opened as OUTPUT.

Records from INPUT file needs to be read one by one and at a same time, those should
be written in OUTPUT file.

9. If ORGANIZATION is defined as
SEQUENTIAL and ACCESS MODE is defined
as INDEXED in SELECT clause, then the file
must be one of these -> KSDS, RRDS, LDS,
ESDS, PS?
If ORGANIZATION IS SEQUENTIAL then the ACCESS MODE must be SEQUENTIAL ONLY.
And these properties are for PS file only.

For KSDS, ORGANIZATION should be INDEXED and access mode can be defined as
SEQUENTIAL, RANDOM, DYNAMIC.

For ESDS, ORGANIZATION should be sequential and access mode can be defined as
sequential.

for RRDS, ORGANIZATION should be relative and access mode can be defined as
SEQUENTIAL, RANDOM, DYNAMIC.

10. If the records need to be written at the


end of file, then how it can be done?
If the records needs to be added at the end of file, then files should be opened in EXTEND
mode.

11. How will you define your record


descriptions in the FILE SECTION if you
want to use three different record
descriptions for the same file?

FD filename
DATA RECORDS ARE rd01, rd02, rd03.
01 rd01 PIC X(n).
01 rd02 PIC X(n).
01 rd03 PIC X(n).
1. Runs scored by 15 players into 25 matches needs to be stored into array.
What kind of array is required to store the same - single or multidimensional?
Define an array.

Array can be defined as


01 PLAYER-DATA.
05 PLAYER-NAME OCCURS 15 TIMES INDEXED BY PL-INDEX PIC X(25).
10 MATCH-RUNS OCCURS 25 TIMES INDEXED BY RUN-INDEX.
15 MATCH RUN PIC 9(3).

To store runs of 25 matches for 15 players, two dimensional array will be required.
PLAYER-NAME stores name of player which occurs 15 times and it has been defined as
X(25). Also for each player, MATCH-RUNS has been defind which occurs 25 times.

2. In above two dimensional array, if runs scored by SACHIN in each


match needs to be displayed, how it can be done?

Using Search
Serial search can be used. First Player Name = "SACHIN" is found using PL-INDEX. Once it
is found then using PL-INDEX, all the run scored by SACHIN can be found out.

SET PL-INDEX TO 1
SET RUN-INDEX TO 1
SEARCH PLAYER-DATA
WHEN PLAYER-NAME(PL-INDEX) = "SACHIN "
DISPLAY 'PLAYER FOUND'
AT END
PERFORM P100-EXIT
END-SEARCH

SET PL-INDEX DOWN BY 1.

PERFORM UNTIL RUN-INDEX < 25


DISPLAY PLAYER-NAME (PL-INDEX,RUN-INDEX)
END-PERFORM.

P1000-EXIT.
EXIT.

Using Perform loop


This task is quite easy using perform loop

SET PL-INDEX TO 1
SET RN-INDEX TO 1
PERFORM UNTIL END-OF-TABLE
IF PL-INDEX = 15
SET END-OF-TABLE TO TRUE

IF PLAYER-NAME(PL-INDEX) = "SACHIN "

PERFORM UNTIL RUN-INDEX < 25

DISPLAY PLAYER-NAME (PL-INDEX,RUN-INDEX)


END-PERFORM
SET END-OF-TABLE TO TRUE

END-IF
END-PERFORM

3. What is sequential search and Binary search ?


In Sequential search, table elements are searched sequentially using SEARCH verb.
When table element is found, control comes out of search. If table element is not found,
action defined at AT END verb is performed.

In Binary search, table must be ordered(sorted in ascending or descending) on the KEYS


specified in the occurs [Link] test in when condition must be always equal
condition(same is not true with Sequential search. In sequential search we can have
unequal conditions in WHEN). Also we can have only one when condition in binary search
(Whereas in sequential search, we can have mutilple when conditions)

In binary search data is search using SEARCH-ALL verb. Table will be devided into two
parts and key will be tested. If the key to be searched lies in first part, then second part
will be elliminated and search will continue in first [Link] will repeat until key is
found or no specified key found in table.
If no specified key found, then action specified at AT END clause is performed.

4. Sequential search or Binary search - When to use what?


Serial search is used if table to be searched is relatively small. Binary search is more
efficient if size of table to be searched in big.

Also for binary search, table needs to have key and data must be in sorted order on a
key. If the data is not like this , then serial search is performed.

5. Can SEARCH and SEARCH ALL be used to find records in a sequential file?
SEARCH and SEARCH all cannot be used to find data in sequental file directly. They can
be used with tables which are declared in the program in DATA division.

However, file records can be loaed into table and they can be searched.

6. What is difference between index and subscript ?


Index and subscript are used for refering a data element into table.

A subscript is a working storage data definition item, typically an interger PIC (999)
where a value must be moved to the subscript and then incremented or decremented by
ADD TO and SUBTRACT FROM statements. Subscript represents an occurence number of
a table within a table.

An index is a register item that exists outside the program's working storage. You SET an
index to a value and SET it UP BY value and DOWN BY value. An index is displacement
from the start of table based upon length of table element.

index values can be changed by SET, PERFORM and SEARCH.

7. A table needs to be defined to store the names of students in the class.


Maximum number of students in class can be 100. Table needs to be defined to
store names of only those students who have taken admissions. Number of
students who have taken admission can be retrieved from WS-ADM-COUNT.
Define an table.

Table can be defined in following way

01. WS-ADM-COUNT PIC 9(2).


01. WS-STUDENTS.
05. WS-STUDENT-NAME OCCURS 1 TO 100 TIMES DEPENDING ON WS-ADM-COUNT
PIC X(25).

With above definition, WS-STUDENTS will be variable length table. Depending upon value
in WS-ADM-COUNT, occurences of WS-STUDENT-NAME will be set.

if WS-ADM-COUNT has value 50, then above table will have data for 50 occurences or
allocate data into storage for 50 occurences.

8. How to set an WS-INDEX to 25? How to set WS-INDEX to WS-INDEX minus(-)


2

To set WS-INDEX to 25 -> SET WS-INDEX TO 25


To set WS-INDEX to WS-INDEX-2 -> SET WS-INDEX DOWN BY 2.

9. If 10 Dimension table needs to be defined in COBOL? Define any 10


dimensional table?

Tables upto 7 dimensions can be defined in COBOL

10. A two dimensional array has been defined in following way. What it does?

01. WS-TABLE OCCURS 10 TIMES PIC X(3).


05 WS-TABLE2 OCCURS 5 TIMES PIC X(5).

Above definition is wrong, since OCCURS clause cannot be specified at 01 [Link] two dimensional
array is required, above defintion can be modified as

01. WS-TABLE-GROUP.
05 WS-TABLE OCCURS 10 TIMES PIC X(3).
10 WS-TABLE2 OCCURS 5 TIMES PIC X(5).

VSAM Questions

[Link] difference between KSDS and ESDS?

KSDS record can be accessed by primary key. ESDS record can be accessed
randomly with displacement address (RBA)

[Link] is AMS in VSAM?


AMS stands for access method services. It is used to create and maintain
datasets

[Link] is SHAREOPTIONS?

It states how the file will be shared between jobs, batch and CICS

[Link] is //Trans DD Dummy, AMP=’AMORG’?

This refers to vsam dataset

[Link] name for ESDS must be prefixed with “AS-“?

//AS-TRANS DD DSN=xyz

[Link] ESDS used in CICS?

ESDS extensively used in online CICS. Since CICS can get access to record
through “RBA”

[Link] we need to use ESDS as GDG?

ESDS can not be used as GDG.

[Link] is default?

Indexed- KSDS, Nonindexed-ESDS, Numbered-RRDS. Out of these “Indexed


” is default parameter.

[Link] is CA/CI level split?

CA/CI level spilts causes performance degradation. If splits are more it causes
more I/O, and reduce the performance.

[Link] is verify?

Verify command close the file correctly. Sample code

//SYSIN DD *
PRINT INDATASET([Link].V339000) DUMP
ALTER [Link] UNINHIBIT
ALTER [Link] UNINHIBIT
VERIFY DATASET([Link])
LISTC ENT([Link]) ALL
/*

JCL
JCL-FAQs (Mainframe Top Interview Questions/Mainframe Refresher/Mainframe
FAQ)

IF THE JOB CARD HAS TIME=NOLIMIT/1440, all time parameters coded in the EXEC
statements are nullified. All those steps will have unlimited time to execute.

//JOB1 JOB (AAAA), ‘ ‘, TIME= 6


//STEP1 EXEC PGM=AAA, TIME=2
//….
//STEP2 EXEC PGM=BBB, TIME=6

1. STEP1 should run for 2 mins as 2 is smaller than 6 (job card time value)
2. STEP2 should run for only 4 minutes as (job card has 6 and 2 already completed
so it has only 4)

1. What is primary allocation for a dataset?

The space allocated when the dataset is first created.

2. What is the difference between primary and secondary allocations for a dataset?

Secondary allocation is done when more space is required than what has already
been allocated.

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

16 extents on a volume for a sequential file and 123 for a VSAM file.

4. What does a disposition of (NEW,CATLG,DELETE) mean? – GS

That this is a new dataset and needs to be allocated, to CATLG the dataset if the step is
successful and to delete the dataset if the step abends.

5. What does a disposition of (NEW,CATLG,KEEP) mean? – GS

That this is a new dataset and needs to be allocated, to CATLG the dataset if the step is
successful and to KEEP but not CATLG the dataset if the step abends. Thus if the step
abends, the dataset would not be catalogued and we would need to supply the vol. ser
the next time we refer to it.

BLKSIZE = 0 -Specifies the maximum length of a physical block of storage in MVS.

MSGLEVEL

Specifies the type of messages to be written to the output destination specified in


the MSGCLASS. Following is the syntax:
MSGLEVEL=(ST, MSG)
ST = Type of statements written to output log
 When ST = 0, Job statements only.
 When ST = 1, JCL along with symbolic parameters expanded.
 When ST = 2, Input JCL only.
MSG = Type of messages written to output log.
 When MSG = 0, Allocation and Termination messages written upon abnormal
job completion.
 When MSG = 1, Allocation and Termination messages written irrespective of
the nature of job completion.

TYPRUN SCAN -> Check syntax errors

TYPRUN – HOLD -> puts the job on HOLD in the job queue

TIME=(mm, ss) or TIME=ss – specifies the span toa be used by the processor
to execute the job.

Statements in JCL – JOB,EXEC,DD – starts from 12th byte in jcl

If a temporary dataset created by a job step is to be used in the next job step, then it
is referenced as DSN=*.[Link]. This is called Backward Referencing.

KEEP is the only valid disposition for VSAM files. This is to be used only for
permanent datasets.

DISP = (Status, Normal Disposition, Abnormal Disposition)

6. How do you access a file that had a disposition of KEEP? – GS

Need to supply volume serial no. VOL=SER=xxxx.


7. What does a disposition of (MOD,DELETE,DELETE) mean ?

The MOD will cause the dataset to be created (if it does not exist), and then the two
DELETEs will cause the dataset to be deleted whether the step abends or not. This
disposition is used to clear out a dataset at the beginning of a job.

8. What is the DD statement for a output file?

Unless allocated earlier, will have the foll parameters: DISP=(NEW,CATLG,DELETE), UNIT ,
SPACE & DCB .

9. What do you do if you do not want to keep all the space allocated to a dataset? – GS

Specify the parameter RLSE ( release ) in the SPACE e.g. SPACE=(CYL,(50,50),RLSE)

[Link] is DISP=(NEW,PASS,DELETE)?

This is a new file and create it, if the step terminates normally, pass it to the subsequent
steps and if step abends, delete it. This dataset will not exist beyond the JCL.

11. How do you create a temporary dataset? Where will you use them?

Temporary datasets can be created either by not specifying any DSNAME or by


specifying the temporary file indicator as in DSN=&&TEMP. We use them to carry the
output of one step to another step in the same job. The dataset will not be retained once
the job completes.

[Link] do you restart a proc from a particular step? – GS

In job card, specify RESTART= [Link] where procstep = name of the jcl step
that invoked the proc and stepname = name of the proc step where you want execution
to start

[Link] do you skip a particular step in a proc/JOB? – GS

Can use either condition codes or use the jcl control statement IF (only in ESA JCL)

14.A PROC has five steps. Step 3 has a condition code. How can you override/nullify this
condition code? – GS
Provide the override on the EXEC stmt in the JCL as follows: //STEP001 EXEC
procname,[Link]=value All parameters on an EXEC stmt in the proc such as
COND, PARM have to be overridden like this.

[Link] do you override a specific DDNAME/SYSIN in PROC from a JCL?

//<[Link]> DSN=…

[Link] is NOTCAT 2 – GS

This is an MVS message indicating that a duplicate catalog entry exists. E.g., if you
already have a dataset with dsn = ‘[Link]’ and u try to create one with disp
new,catlg, you would get this error. the program open and write would go through and at
the end of the step the system would try to put it in the system catalog. at this point
since an entry already exists the catlg would fail and give this message. you can fix the
problem by deleting/uncataloging the first data set and going to the volume where the
new dataset exists(this info is in the msglog of the job) and cataloging it.

[Link] is ‘S0C7’ abend? – GS

Caused by invalid data in a numeric field.

[Link] is a S0C4 error ? – GS

Storage violation error – can be due to various reasons. e.g.: READING a file that is not
open, invalid address referenced due to subscript error.

[Link] are SD37, SB37, SE37 abends?

All indicate dataset out of space. SD37 – no secondary allocation was specified. SB37 –
end of vol. and no further volumes specified. SE37 – Max. of 16 extents already
allocated.

[Link] is S322 abend ?

Indicates a time out abend. Your program has taken more CPU time than the default limit
for the job class. Could indicate an infinite loop.

[Link] do you want to specify the REGION parameter in a JCL step? – GS


To override the REGION defined at the JOB card level. REGION specifies the max region
size. REGION=0K or 0M or omitting REGION means no limit will be applied.

[Link] does the TIME parameter signify ? What does TIME=1440 mean ?

TIME parameter can be used to overcome S322 abends for programs that genuinely need
more CPU time. TIME=1440 means no CPU time limit is to be applied to this step.

[Link] is COND=EVEN ?

Means execute this step even if any of the previous steps, terminated abnormally.

[Link] is COND=ONLY ?

Means execute this step only if any of the previous steps, terminated abnormally.

[Link] do you check the syntax of a JCL without running it?

TYPERUN=SCAN on the JOB card or use JSCAN.

[Link] does IEBGENER do?

Used to copy one QSAM file to another. Source dataset should be described using
SYSUT1 ddname. Destination dataset should be decribed using SYSUT2. IEBGENR can
also do some reformatting of data by supplying control cards via SYSIN.

[Link] do you send the output of a COBOL program to a member of a PDS?

Code the DSN as pds(member) with a DISP of SHR. The disp applies to the pds and not to
a specific member.

28.I have multiple jobs ( JCLs with several JOB cards ) in a member. What happens if I
submit it?

Multiple jobs are submitted (as many jobs as the number of JOB cards).

29.I have a COBOL program that ACCEPTs some input data. How do you code the JCL
statment for this? (

How do you code instream data in a JCL? )


//SYSIN DD* input data input data /*

[Link] you code instream data in a PROC ?

No.

31. How do you overcome this limitation ?

One way is to code SYSIN DD DUMMY in the PROC, and then override this from the JCL
with instream data.

[Link] do you run a COBOL batch program from a JCL? How do you run a COBOL/DB2
program?

To run a non DB2 program, //STEP001 EXEC PGM=MYPROG

To run a DB2 program, //STEP001 EXEC PGM=IKJEFT01 //SYSTSIN DD * DSN SYSTEM(….)


RUN PROGRAM(MYPROG) PLAN(…..) LIB(….) PARMS(…) /*

[Link] is STEPLIB, JOBLIB? What is it used for? – GS

Specifies that the private library (or libraries) specified should be searched before the
default system libraries in order to locate a program to be executed.

STEPLIB applies only to the particular step, JOBLIB to all steps in the job.

[Link] is order of searching of the libraries in a JCL? – GS

First any private libraries as specified in the STEPLIB or JOBLIB, then the system libraries
such as [Link]. The system libraries are specified in the linklist.

[Link] happens if both JOBLIB & STEPLIB is specified ?

JOBLIB is ignored.

[Link] you specify mutiple datasets in a JOBLIB or STEPLIB, what factor determines the
order? – GS

The library with the largest block size should be the first one.
[Link] to change default proclib ?

//ABCD JCLLIB ORDER=([Link],[Link])

[Link] disp in the JCL is MOD and the program opens the file in OUTPUT mode. What
happens ? The disp in the JCL is SHR and the pgm opens the file in EXTEND mode. What
happens ?

Records will be written to end of file (append) when a WRITE is done in both cases.

[Link] are the valid DSORG values ?

PS – QSAM, PO – Partitioned, IS – ISAM

[Link] are the differences between JES2 & JES3 ?

JES3 allocates datasets for all the steps before the job is scheduled. In JES2, allocation of
datasets required by a step are done only just before the step executes.

CLASS – Categorize the jobs SHORT RUN or LONG RUN

MSGCLASS – Where the JCL messages to be routed

MSGLEVEL =([Statements], [Messages])

Statements –

0 – JCL internal messages (JOB statement, all comments etc and )


1 - All statements (Job statements + procedure statements + symbolic parameter
expansions)
2 – JES2 or JES3 control statements

Messages –

0 – Messages will be displayed if job ended ABNORMALLY

1- Both NORMALLY AND ABNORMALLY


PRTY – Assigns a value for priority 0-15 for JES2 and 0-14 for JES3

Highest number in PRTY decides which job to run first.

REGION – Storage to execute the job.

TYPRUN = SCAN OR HOLD (Hold the job until operator release the job)

STEPLIB – private library where COBOL programs will be searched for – MAX 255 steplibs
in job – Picks libs in the order they are coded

JOBLIB – private library where COBOL program LOADs will be searched for - Picks libs in
the order they are coded – But steplibs overrides joblib

JCLLIB – Identify private librabries – PROCs stored and group of JCL stats on INCLUDE.

COPYLIB – Search copybooks during the compilation of program

SYSABEND – Dumps info if job abended abnormally. If job ran fine, even though
SYSABEND is coded it will not produce dump – SYSABEND DD -> summary of dumping
program

SYSMDUMP DD – same as above but DUMP is unformatted & only Abend dumps nothing
else

SYSUDUMP DD – Dump is formattable and readable

IEBGENR – Only copy datasets but can’t create datasets

IEFBR14 – Create

How to check if file is empty in JCL?

Sort card to check record count in JCL?

What happens If we OPEN INPUT for a file having DISP=NEW? Logical error with file
status code
If file is OPEN INPUT-OUTPUT mode – if you close and open then records are still there.

If file is OPEN INPUT-OUTPUT mode then DISP shouldn’t be OLD – Check this

DISP parameter –

NEW

OLD -Only input

MOD

SHR -Both Input & Output (Not recommendable)

ALL COMPs have value boundaries along with storage boundaries

COMP 32767 – If I send 30000 it will take if I send 40000 it wont take

COMP- 3 always take sign bit as mandatory in 1 BIT

If you give odd number size in comp-3 – storage is saved

Even – 1 nibble is wasted

How to get date from JCL/COBOL PGM ?

What is db2 date format – CCYY-MM-DD


JCL

CLASS – Highest class will be picked up first based by configurations.


PRTY – Which has high PRTY will run first.
MSG CLASS – will define where the output will be routed to
*IN THE JCL is to refer back.
What messages will be routed? MSGLEVEL= ( 1,1) – DEFAULT
0 & 1 – What messages to be routed
0&1&2–
NOTIFY

Can I have 2 job cards in the JOB – 255, each job is separately spooled in spool
area.
A job can have a maximum of 255 job steps
Max DD statements – 3273 in a job.
JCL Statements – JOB, EXEC, DD – Only 3 statements
Can I submit the without EXEC & DD and only with JOB CARD??
POSITIONAL Parameters – If we give parm instead of proc or pgm – syntax
error will come – ‘Positional parameters missing’. So PGM & PROC are
positional parameters in EXEC statement.
Account information is a positional parameter in JOB statement.

Keyword parameter – Rule of Key=value

Common keyword parameters for JOB & EXEC statements –


TIME/REGION/COND.

Condition parameter – will control the flow of job execution. If don’t mention
the condition parameter then job will execute step by step – COND
One more parameter is RESTART parameter – Condition parameter.

3steps in my job.
S1 p1 – a b c
S2 p2 - def
S3 p3 – xyz
Execute from y
RESTART – [Link] in the proc – S3.Y
Nested procedures in RESTART

S3 P3 (PX) – [Link] in the proc

3steps – 4,3,2,1 – IEBEDIT utility – Create one more job – Control card lo
give step4,3,2,1 ddname – where job resides. So submit iebedit job don’t
need to submit main job.
COND= (RC, Relational operator, STEPNAME) –
COND=ONLY – Only previous step abend then only it should execute
COND=EVEN

Max conditions 15 in COND parameter.


Flush u can see in RC if u bypass steps.

Any positional parameter in DD ?

Creating a file DCB parameter is not at all mandatory.


For step PGM=SORT * SORT=COPY – DCB parameters is not at all
mandatory.

Input file is let’s say 100


OUTREC BUILD = 1,20 – Output file length is 20 bytes.

LRECL MISMATCH ERROR – File status 39.


Load module not found – S806 Abend
Steplib – joblib – system default library
JCLLIB/ PROCLIB – Where PROCS will be searched for.

GDG – To maintain backup versions.


Limit
Scratch
No scratch
Empty
NoEmpty

How to create an EMPTY FILE in job – nullfile & dummy


How to check empty file
1. ICETOOL – We didn’t buy and it is not freeware
2. IDCAMS – Freeware of IBM Utilities
STEP01 EXEC PGM=IDCAMS
DD1 DD DSN=

PRINT FILE(DD1NAME) COUNT(1) – In control card


Atleast 1 record present means give 0 else give me 4
COND=(4,EQ) in STEP02.
TRAILING OR LEADING – One of them doesn’t work in INSECT
REVERSE STRING we can use and do the task.

Can we give 9(8) comp-3 ?? check.


Positive value isthey last nibble lo ‘C’ store avuthadhi
Negative value isthey last nibble lo ‘D’ store avuthadhi
9(8) COMP-3  F is stored in last nibble.

If a generation dataset is specified as input without generation number, then? –


Concatenation of all the Catalogued datasets.
TCS Questions
1. Writing matching records into one file and unmatching records into another
file – Both COBOL & JCL (JOINKEYS).
2. A file has name and marks. Write average marks into one file and total marks
into another file. (multiple records can have same name)
3. Get second highest salary – tell any 2 types of queries
4. Get Max and Min of salary in same query

You might also like