0% found this document useful (0 votes)
70 views5 pages

Cobol Quiz 04

The document contains answers to various questions about COBOL programming. It discusses differences between INCLUDE and COPY statements, between GOBACK, STOP RUN and EXIT PROGRAM, and between DELIMITED BY SPACE and DELIMITED BY SIZE. It also explains search techniques in COBOL like SEARCH and SEARCH ALL, differences between binary and sequential searches, causes of various abend codes, differences between subscript and index, and more.

Uploaded by

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

Cobol Quiz 04

The document contains answers to various questions about COBOL programming. It discusses differences between INCLUDE and COPY statements, between GOBACK, STOP RUN and EXIT PROGRAM, and between DELIMITED BY SPACE and DELIMITED BY SIZE. It also explains search techniques in COBOL like SEARCH and SEARCH ALL, differences between binary and sequential searches, causes of various abend codes, differences between subscript and index, and more.

Uploaded by

achyutinamdar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

1. What is the distinction among INCLUDE and COPY?

Answer: They both help to expand variables/codes in a program. The critical difference
is INCLUDE gets extended at PRE-COMPILATION & COPY expands during compilation time. DB2 pre-
compiler can’t process COPY statements, not it connect to DB2 directories to validate the Table
Attributes (Columns, Name, Data Type) and thus the DCL statements embedded in INCLUDE.

2. State the difference between GOBACK, STOP RUN and EXIT PROGRAM in COBOL?
Answer: The fundamental differences between GOBACK, STOP RUN, and EXIT PROGRAM in COBOL
are:
• GOBACK returns control to the calling program
• STOP RUN stops the present work unit and returns control to OS
• EXIT PROGRAM is utilized to leave a program that has been called by another program

3. Define DELIMITED BY SPACE and DELIMITED BY SIZE along with their utilization?
Answer: DELIMITED BY SPACE or DELIMITED BY SIZE will be utilized alongside the STRING for
controlling the information in case it is replicated.
• DELIMITED BY SIZE: Total size of information things would be considered as the delimiter,
• DELIMITED BY SPACE: Space would be considered as the delimiter

4. What are various search techniques in COBOL? Explain. What is the difference between SEARCH
and SEARCH ALL?
Answer: There are 2 searching techniques in COBOL.
Serial search: SEARCH
• It is a process of finding a particular value in a given list.
• The search is implemented by checking each element in the list, one at a time and in sequence.
• This process is continued until the desired element is found.
• SEARCH is used for serial search.
Binary Search: SEARCH ALL
• It is a process of finding a particular element in a sorted list.
• The binary search starts by comparing the middle element of the array.
• The comparison determines the element’s location – either in the first half of the list or in the
second half of the list.
• This process continues until the search element is equal to the middle element of the list
• SEARCH ALL is used for binary search.
• The list must be sorted by using the ASCENDING / DESCENDING KEY clause, which loads.
• The default key is ASCENDING KEY.

5. What is the difference between a binary search and a sequential search?


Answer: In a binary search, the table element key values will be in ascending or descending
sequence. The table is ‘halved'(Divided into two) to search for equal to, greater than or less than
conditions until the element is found.
In a sequential search, the table is searched from top to bottom, so the elements do not have to be
in a specific sequence.
The binary search is much faster for more tables, while sequential Search works well with lesser
ones. SEARCH ALL is used for binary search; SEARCH for sequential search.

6. What is SOC-7 abend? What do you do to resolve SOC-7 error?


Answer: Many times the reason for SOC7 is an un-initialized numeric item.
a. Offending data need to be corrected, focus on examining this.
b. A lot of installations provide a dump for run time abends, and these abends provide the offset
which is returned by the last instruction where the abend occurred.
c. Focus on examining the compilation output XREF listing to find the verb and the line number
within the source code at this offset.
d. Later investigate the source code for finding the bug.
e. Define certain datasets(SYSABOUT etc) in JCL, for capturing runtime dumps.
f. At times few installations might have batch program debugging tool. Utilize them to resolve the
issue.

7. What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY)?


Answer: These are the options of compile/link editing:
AMODE: Addressing Mode.
• AMODE(24): It is a 24-bit addressing mode.
• AMODE(31): It is a 31-bit addressing mode.
• AMODE(ANY): Either 24 bit or 31-bit address mode depending upon RMODE.
RMODE: Resident mode.
• RMODE(24): It resides within virtual storage below 16 Meg line.
a. Programs of 31 bit which call 24-bit programs are preferred to use this mode.
b. RMODE(ANY): Either 24 bit or 31-bit address mode depending upon RMODE.
c. OS/VS COBOL program uses 24-bit address only.
• RMODE(ANY): This mode can reside below or above 16 Meg line.

8. Explain what you understand by passing BY VALUE.


Answer: It means that the program/method passes the value of the identifier or literal. It does not
imply a reference to the sending data item. The program/method called has the capability to change
the parameter in the called/invoked program/method. But there is no effect on the argument value
in the calling program as the subprogram/method has access to a temporary copy of the sent data
item. The parameters used should always be of a particular defined data type in case the data is to
be passed somewhere else. This is different as compared to BY CONTENT, as it does not, passes only
the contents of the identifier.

9. What do you understand by passing by reference and passing by content?


Answer: Passing by reference:
• When between programs data is shared or passed the subprogram always refers and processes the
data items within the calling programs storage.
• It does not work on the copy of the data. Whenever a call by reference identifier is used the caller
and the called share the same memory.
Passing by content:
• In this case, the calling program only passes the contents of the identifier or the literal.
• When this is used the called program is unable to change the value of the identifier or the literal in
the program being called. Further, it cannot change the value even if it has modified the variable
through which it received its literal.

10. State the various causes of S0C1, S0C5, and S0C7.


Answer: S0C1 can be caused due to:
• A misspelled DD name.
• Read/Write to a dataset that is unopened.
• The subprogram called cannot be found.
• Read to the dataset for an opened output.
S0C5 can be caused due to:
• A bad or damaged Subscript/index.
• An incorrect exit from a preform.
• The I/O area is accessed before reading.
• An unopen dataset is closed.
S0C7 can be caused due to:
• A numeric operation is performed in a non-numeric data.
• Working storage is un-initialized.
• Excess coding past the max permitted dub script.

11. What is the difference between subscript and index?


Answer: Subscript refers to the occurrence of an array but the Index is the displacement from the
beginning of the array. An index can only be modified using PERFORM, SEARCH & SET. Need to have
indexed for a table in order to use SEARCH, SEARCH ALL.

12. What is the difference between performing a SECTION and a PARAGRAPH?


Answer: SECTION will have all the paragraphs that are part of the section, to be
performed. PARAGRAPH will have only that paragraph to be performed.

13. What is the difference between PERFORM … WITH TEST AFTER and PERFORM … WITH TEST
BEFORE?
Answer: If the TEST BEFORE is specified, the condition is tested at the beginning of each repeated
execution of the specified PERFORM range.
If TEST AFTER is specified, the condition is tested at the end of each repeated execution of the
PERFORM range. The range is executed at least once in TEST AFTER.

14. What is Static and Dynamic linking?


Answer: In static linking, called subroutine links into the calling program, while in dynamic linking,
the subroutine & the main program will exist as separate modules. Dynamic and Static linking can be
achieved by choosing either the DYNAM or NODYNAM link edit option.

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.

15. What Is The Difference Between A Dynamic And Static Call In Cobol?
Answer: All called modules cannot run standalone if they require program variables passed to them
via the LINKAGE section. Dynamically called modules are those that are not bound with the calling
program at link-edit time (IEWL for IBM) and so are loaded from the program library (joblib or
steplib) associated with the job. For DYNAMIC calling of a module the DYNAM compiler option must
be chosen, else the linkage editor will not generate an executable as it will expect u address
resolution of all called modules. A Statically called module is one that is bound with the calling
module at link-edit and therefore becomes part of the executable load module.

16. How Can I Tell If A Module Is Being Called Dynamically Or Statically?


Answer: The ONLY way is to look at the output of the linkage editor (IEWL) or the load module itself.
If the module is being called DYNAMICALLY then it will not exist in the main module, if it is being
called STATICALLY then it will be seen in the load module. Calling a working storage variable,
containing a program name, does not make a DYNAMIC call. This type of call is known as IMPLICITE
calling as the name of the module is implied by the contents of the working storage variable. Calling
a program name literal.
17. What kind of error is trapped by ON SIZE ERROR option?
Answer: ON SIZE ERROR option is raised when there is
• fixed-point overflow
• Zero raised to the zero power
• Division by 0
• Zero raised to a negative number
• A negative number raised to a fractional power.

18. What are an SSRANGE and NOSSRANGE?


Answer: These are options for a compiler to find the subscript out of range.
SSRANGE is a compiler option that handles the array overflow. SSRANGE also needs to be specified
in COBOL programing language. These help in finding the subscript out of range.
NOSSRANGE is used for performance sensitive applications. NOSSRANGE is a default option that
doesn’t support any runtime error if the index or subscript runs out of range.

19. 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?
Answer: Must use compiler option SSRANGE if you want array bounds checking. Default
is NOSSRANGE. If no options provided then it will abend with SOC4 -An Invalid address referenced
due to subscript/index error.

20. What is the difference between the NEXT SENTENCE and CONTINUE in COBOL programing
language?
Answer: In COBOL language, NEXT STATEMENT is used to give control to the next verb following the
next period. Next Sentence is the collection of sentences that always ends with (.) so the control
passes over to the next verb following the next period. When the NEXT SENTENCE is coded, 1 will
not be added to input count.
CONTINUE statement is used to give control to the next verb after the explicit scope terminator.
When CONTINUE is coded, +1 will be added to input count.

21. When would you use in-line perform?


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

22. How is sign stored in Packed Decimal fields and Zoned Decimal fields?
Answer: 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 overpunched with the numeric value stored in the last bite.

23. What is the difference between CONTINUE and NEXT SENTENCE?


Answer: CONTINUE transfers the control to the next statement after the scope terminator, it’s like a
null statement. NEXT SENTENCE transfers the control to the statement after the first period is
encountered.

24. What Is Comp Sync?


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

25. Why Do We Code S9 (4) Comp. Inspite Of Knowing Comp-3 Will Occupy Less Space ?
Answer: Here S9(4) comp is a small integer, so two words equal to 1 byte so totally it will occupy 2
bytes(4 words). In s9(4) comp-3 as one word is equal to 1/2 byte.4 words equal to 2 bytes and sign
will occupy 1/2 byte so totally it will occupy 3 bytes.

26. What Care Has To Be Taken To Force Program To Execute Above 16 Meg Line?
Answer: Make sure that link option is AMODE=31 and RMODE=ANY. Compile option should never
have SIZE (MAX). BUFSIZE can be 2K, efficient enough.

27. What is a reentrant program? How will you make a program Reentrant?
Answer: A reentrant program, while being executed resides in the common virtual area so that one
copy of it may be shared among all callers. Use RENT compiler option.

28. 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.

29. How will you count the number of characters in a null-terminated string?
Answer: MOVE 0 TO char-count
INSPECT null-terminated-string TALLYING char-count FOR CHARACTERS BEFORE X”00″

30. What are the causes for S0C1, S0C4, S0C5, S0C7, S0CB abends
Answer: S0C1 – Maybe due to
1.Missing or misspelled DD name
2.Read/Write to the unopened dataset
3. Read to dataset opened the output
4. Write to dataset opened input
5. Called subprogram not found.

You might also like