Latest Mainframe Interview Questions and Answers
When 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 paraname rather than in-line perform.
How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy ?
Will occupy 8 bytes (one extra byte for sign).
Name the divisions in a COBOL program.
My program has an array defined to have 10 items. Due to a bug, I find that even if the program access 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.
What is the difference between CONTINUE & NEXT SENTENCE ?
CONTINUE is like a null statement (do nothing) , while NEXT SENTENCE transfers control to the next sentence (!!) (A sentence is terminated by a period)
How many bytes will a S9(8) COMP field occupy ?
What are the different data types available in COBOL?
Alpha-numeric (X), alphabetic (A) and numeric (9).
How do you sort in a COBOL program? Give sort file definition, sort statement syntax and meaning.
SORT file-1 ON ASCENDING/DESCENDING KEY key….
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.
What does EXIT do ?
Does nothing ! If used, must be the only sentence within a paragraph.
What is the maximum value that can be stored in S9(8) COMP?
What does the INITIALIZE verb do?
Alphabetic, Alphanumeric fields & alphanumeric edited items are set to SPACES.
Numeric, Numeric edited items set to ZERO.
FILLER , OCCURS DEPENDING ON items left untouched.
How 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.
Can 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.
What 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.
What is 77 level used for ?
Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves.
How many Sections are there in Data Division?.
Ans: SIX SECTIONS 1.’FILE SECTION’ 2.’WORKING-STORAGE SECTION’ 3.’LOCAL-STORAGE SECTION’ 4.’SCREEN SECTION’ 5.’REPORT SECTION’ 6.’LINKAGE SECTION’
In COBOL II, there are only 4 sections. 1.’FILE SECTION’ 2.’WORKING-STORAGE SECTION’ 3.’LOCAL-STORAGE SECTION’ 4.’LINKAGE SECTION’.
Can I redefine an X(200) field with a field of X(100) ?
What is the maximum size of a 01 level item in COBOL I? in COBOL II?
In COBOL II: 16777215
What is 88 level used for ?
For condition names.
Give the format of USING and GIVING in SORT statement. What are the restrictions with it?
See question 16. Restrictions – Cannot massage records, canot select records to be sorted.