Cobol Quiz 04
Cobol Quiz 04
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.
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.
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.
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.
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.
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.