Mainframe COBOL Frequently Asked Questions and Answers

10/20/2009 No Comment

References to COBOL Mainframe Programming.

COBOL Interview Questions, Answers and Explanations.

What are the few advantages of VS COBOL II over OS/VS COBOL?
Answer : The working storage and linkage section limit has been increased. They are 128 megabytes as supposed to 1 megabytes in OS/VS COBOL.
Introduction of ADDRESS special register.
31-bit addressing. In using COBOL on PC we have only flat files and the programs can access only limited storage, whereas in VS COBOL II on M/F the programs can access up to 16MB or 2GB depending on the addressing and can use VSAM files to make I/O operations faster

What are the steps you go through while creating a COBOL program executable? 

Answer : DB2 pre-compiler (if embedded SQL is used), CICS translator (if CICS program), Cobol compiler, Link editor. If DB2 program, create plan by binding the DBRMs.

Name the divisions in a COBOL Program.

Answer : Identification / Environment/ Data/ Procedure Divisions

What are the different data types available in COBOL?

Answer : Alpha-numeric (X) , Alphabetic (A) and numeric (9).

What does the INITIALIZE verb do?

Answer : Alphabetic, Alphanumeric fields & alphanumeric edited items are set to SPACES. Numeric, Numeric edited items set to ZERO. FILLER , OCCURS DEPENDING ON items left untouched

What is the difference between a 01 level and 77 levels?

Answer : 01 level can have sublevels from 02 to 49. 77 cannot have sublevel.

What are 77 levels used for?

Answer : Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves.

What is 88 level used for?

Answer : For condition names.

What is level 66 used for?

Answer : For RENAMES clause.

What does the IS NUMERIC clause establish?

Answer : 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 - .

Is compute w=u a valid statement?

Answer : Yes, it is. It is equivalent to move u to w.

In the above example, when will you prefer compute statement over the move statement?

Answer : When significant left-order digits would be lost in execution, the COMPUTE statement can detect the condition and allow you to handle it. The MOVE statement carries out the assignment with destructive truncation. Therefore, if the size error is needs to be detected, COMPUTE will be preferred over MOVE. The ON SIZE ERROR phrase of COMPUTE statement, compiler generates code to detect size-overflow.

What happens when the ON SIZE ERROR phrase is specified on a COMPUTE statement?

Answer : If the condition occurs, the code in the ON SIZE ERROR phrase is performed, and the content of the destination field remains unchanged. If the ON SIZE ERROR phrase is not specified, the assignment is carried out with truncation. There is no ON SIZE ERROR support for the MOVE statement.

How will you associate your files with external data sets where they physically reside?

Answer : Using SELECT clause, the files can be associated with external data sets. The SELECT clause is defined in the FILE-CONTROL paragraph of Input-Output Section that is coded Environment Division. The File structure is defined by FD entry under File-Section of Data Division for the OS.

How will you define your file to the operating system?

Answer : Associate the file with the external data set using SELECT clause of INPUT-OUTPUT SECTION. INPUT-OUTPUT SECTION appears inside the ENVIRONMENT DIVISION.

Explain the use of Declaratives in COBOL?

Answer : Declaratives provide special section that are executed when an exceptional condition occurs. They must be grouped together and coded at the beginning of procedure division and the entire procedure division must be divided into sections. The Declaratives start with a USE statement. The entire group of declaratives is preceded by DECLARIVES and followed by END DECLARITIVES in area A. The three types of declaratives are Exception (when error occurs during file handling), Debugging (to debug lines with 'D' coded in w-s section) and Label (for EOF or beginning...) declaratives.

How do you define a table/array in COBOL?Answer : 

Can the OCCURS clause be at the 01 level?

Answer : No

A statically bound subprogram is called twice. What happens to working-storage variables?

Answer : The working-storage section is allocated at the start of the run-unit and any data items with VALUE clauses are initialized to the appropriate value at the time. When the subprogram is called the second time, a working-storage items persist in their last used state. However, if the program is specified with INITIAL on the PROGRAM-ID, working-storage section is reinitialized each time the program is entered.

Significance of the COMMON Attribute ?

Answer : COMMON attribute is used with nested COBOL programs. If it is not specified, other nested programs will not be able to access the program. PROGRAM-ID. Program name is COMMON PROGRAM.

In which division and section, the Special-names paragraph appears?

Answer : Environment division and Configuration Section.


Answer : Local-Storage is allocated each time the program is called and is de-allocated when the program returns via an EXIT PROGRAM, GOBACK, or STOP RUN. Any data items with a VALUE clauses are initialized to the appropriate value each time the program is called. The value in the data items is lost when the program returns. It is defined in the DATA DIVISION after WORKING-STORAGE SECTION

What does passing BY REFERENCE mean?

Answer : When the data is passed between programs, the subprogram refers to and processes the data items in the calling program's storage, rather than working on a copy of the data. When CALL . . . BY REFERENCE identifier. In this case, the caller and the called share the same memory.
Related Posts

No comments :


Aired | The content is copyrighted and may not be reproduced on other websites. | Copyright © 2009-2016 | All Rights Reserved 2016

Contact Us | About Us | Privacy Policy and Disclaimer