Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

COBOL Refresher QA (Topic wise)

1. COBOL Coding Guideline


- Random-Q:

2. COBOL
- Random-Q:

3. COBOL

4. JCL
- Random-Q:

5. COBOL
- Random-Q:

6. COBOL
COBOL Coding Guideline

1. How many Divisions are used in a COBOL code? Describe the usage of
each division.
A.
There are four division presents in a COBOL code. The divisions are,

a) Identification Division - It identifies a program by giving the program name.

b) Environment Division - It includes the Input-Output Section, which identifies


the Input and output files used by the program.

c) Data Division - It includes the File Section and the Working-Storage Section.
The File Section describes the files identified in the Input-Output
Section, and the Working-Storage Section defines other data items
used by the program.

d) Procedure Division – It contains the program logic. It is typically divided into


procedures that contain the statements that do the
functions of the program.
2. How indent/column rule is used for COBOL coding?
A.
Each line of a Cobol Code is made of 80 Columns, which follows the below grid rule.

3. What is the naming convention for the program-id?


A.
- The length of the program name should be 8 characters or less in IBM mainframe.
- Name should start with alphabet only and
- It can contain numbers except the beginning position.

4. What is the syntax rule to code an ID division?


A.
All the entries in IDENTIFICATION DIVISION should be coded in AREA A
5. What is the naming convention for data-name declaration?
A.
-A data-name can comprise letters, numbers, hyphens and
-Each data-name can be of max 30 characters.
-Don’t start or end the name with a hyphen.
-Use at least one letter in the name.
-Code a period at the end of each data item.
-Don’t use the same name as a COBOL reserved word. Ex- DATA, DIVISION, SECTION,
WORKING-STORAGE, DISPLAY, ACCEPT, and PERFORM.

Since, COBOL program contains dozens of data items; this is a factor to declare the long
names for efficient programming. And the more data names a program uses, the more
important this is.

6. How PIC clause is used?


A.
-The Picture (Pic) clause defines the format of the data that can be stored in the field.

-Each character or digit that you define in a Pic clause requires one byte of internal
storage. So an alphanumeric field that’s defined as X(20) requires 20 bytes of storage,
and a numeric edited field that’s defined as ZZ,ZZZ.99- requires 10 bytes of storage.
-For a numeric item, the V just marks the position of the decimal point so it doesn’t
require a storage byte. Similarly, the S indicates that the data item can include a sign,
but it usually doesn’t require a separate storage byte. As a result, a numeric item that’s
defined as S999V99 usually requires just 5 bytes of internal storage.

- When data is stored in an alphanumeric item, unused positions to the right are set to
spaces. When data is stored in a numeric item, unused positions to the left are set to
zeros.

I) Alphanumeric: one letter, digit, or special character can be stored in the item. Thus,
a data item that’s defined as X(3) can store values like 123, ABC, X2$, or just Y. If an
alphanumeric item contains fewer characters than the picture provides for, unused
positions to the right are filled with spaces.

II) Numeric: When you define a numeric item, you use 9’s to indicate the number of
digits that can be stored in the item. You can also code a leading S to indicate that the
item can have a plus or minus sign, and you can code one V to indicate where the
decimal point is assumed to be. Thus, a data item that’s defined as S999V99 can store
values like +.05 and —999.95. If a numeric item contains fewer digits than the picture
provides for, the unused positions to the left are set to zeros.

III) Numeric Edited: When you define a numeric edited item, you use characters that
make the data in the item easier to read. For instance, you can code a Z when you want a
zero to the left of a number to be changed to a space, and you can use a comma or
decimal point when you want to insert a comma or decimal point into a number. Then,
when the program moves a numeric item to a numeric edited item, the data is converted
to the more readable form. (Discussed later)
7. What rules are followed to define group item?
A.
1. To code group items, you use the level numbers 01 through 49. Typically you will start
with 01, and then use multiples of 5, such as 05 and 10. This allows you some room to
add other levels later if you need to.

2. Level 01 items must begin in the A margin. Other level numbers can begin in either the
A or B margin.

3. Whenever one data item has higher level numbers beneath it, it is a group item and
the items beneath it are elementary items.
In the example below, USER-ENTRIES, WORK-FIELDS, and TODAYS-DATE are group
items. All of the others are elementary items.

4. You can’t code a Picture clause for a group item, but you have to code a Picture clause
for an elementary item.

5. A group item is always treated as an alphanumeric item, no matter how the


elementary items beneath it are defined.
6. To make the structure of the data items easy to read and understand, you should align
the levels as shown above. However, this indentation isn’t required.

COBOL

Q. How
The

COBOL

1. What
A.

C
Q. How
A.

Q. How
A.

Targeted
Q. How
A.

COBOL

1. How?
A.

SORT

1. How
A.
Zoned

1. What
A.

COBOL

1. What
A.

S
S222

COBOL

1. What
A. an

You might also like