Showing posts with label COBOL Interview Questions. Show all posts
Showing posts with label COBOL Interview Questions. Show all posts

COBOL Interview Questions Part 3


21. How do you come out of an EVALUATE statement?
After the execution of one of the when clauses, the control is automatically passed on to the next sentence after the EVALUATE statement. There is no need of any extra code.
22. In an EVALUATE statement, can I give a complex condition on a when clause?
Yes

23. What is a scope terminator? Give examples.
Scope terminator is used to mark the end of a verb e.g. EVALUATE, END-EVALUATE; IF, END-IF.
24. How do you do in-line PERFORM?
PERFORM ... ...

END PERFORM

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

26. 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)
27. What does EXIT do ?
Does nothing ! If used, must be the only sentence within a paragraph.

28. 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.
29. Can I redefine an X(200) field with a field of X(100) ?
Yes.
30.What do you do to resolve SOC-7 error?
Basically you need to correcting the offending data.

Many times the reason for SOC7 is an un-initialized numeric item. Examine that possibility first.

Many installations provide you a dump for run time abends ( it can be generated also by calling some subroutines or OS services thru assembly language). These dumps provide the offset of the last instruction at which the abend occurred. Examine the compilation output XREF listing to get the verb and the line number of the source code at this offset. Then you can look at the source code to find the bug. To get capture the runtime dumps, you will have to define some datasets (SYSABOUT etc ) in the JCL.

If none of these are helpful, use judgement and DISPLAY to localize the source of error.

Some installtion might have batch program debugging tools. Use them.

COBOL Mainframe Interview Questions Part 1


Name the divisions in a COBOL program.
IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION, PROCEDURE DIVISION.
1. What are the different data types available in COBOL?
Alpha-numeric (X), alphabetic (A) and numeric (9).
2. 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.
3. What is 77 level used for ?
Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves.
4. What is 88 level used for ?
For condition names.
5. What is level 66 used for ?
For RENAMES clause.

6. What does the IS NUMERIC clause establish ?
IS NUMERIC can be used on alphanumeric items, signed numeric & packed decimal items and usigned 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 - .
7. What does the IS NUMERIC clause establish ?
IS NUMERIC can be used on alphanumeric items, signed numeric & packed decimal items and usigned 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 - .
8. Can the OCCURS clause be at the 01 level?
No.
9. What is the difference between index and subscript?
Subscript refers to the array occurrence while index is the displacement (in no of bytes) from the beginning of the array. An index can only be modified using PERFORM, SEARCH & SET.

Need to have index for a table in order to use SEARCH, SEARCH ALL.
10. What is the difference between SEARCH and SEARCH ALL?
SEARCH - is a serial search.

SEARCH ALL - is a binary search & the table must be sorted ( ASCENDING/DESCENDING KEY clause to be used & data loaded in this order) before using SEARCH ALL

Difference between dbrm.lib and loadlib in COBOL

Normally when a COBOL-DB2 code is compiled, during pre-compilation process, all the SQL codes embedded in the COBOL code will be extracted and moved into a DBRM. The DBRM will be situated in a system library called DBRM.lib. Once the DBRM is created then binding of the DRBM happens where a package or a plan is created for a particular DBRM or set of DBRM's. After the binding is done. The COBOL code is compiled and the system generated a Object module. After the compilation, link editing takes place where all the sub modules called and copybooks used by this COBOL code will be linked to this Object module, with this a Load module is generated and this is situated in a System library like LOADLIB.LIB.

COBOL TALLYING / BEFORE INTIAL / AFTER INITIAL statements

Give example of Inspect TALLYING / BEFORE INTIAL / AFTER INITIAL. In which situation will use this in COBOL?We have different type of Inspect verb
1.counting INSPECT.
2.replacing INSPECT.
3.combined INSPECT.
4.converting INSPECT.
Give example of any Inspect verb which you know. 


INSPECT word TALLYING count FOR LEADING “L” BEFORE INITIAL “A”, count-1 FOR
LEADING “A” BEFORE INITIAL “L”.
Where word = LARGE, count = 1 and count-1 = 0.
Where word = ANALYST, count = 0 and count-1 = 1.
INSPECT word TALLYING count FOR ALL “L”, REPLACING LEADING “A” BY “E” AFTER
INITIAL “L”.
Nucleus
7830 7709–000 2–103
Where word = CALLAR, count = 2 and word = CALLER.
Where word = SALAMI, count = 1 and word = SALEMI.
Where word = LATTER, count = 1 and word = LETTER.
INSPECT word REPLACING ALL “A” BY “G” BEFORE INITIAL “X”.
Where word = ARXAX, word = GRXAX.
Where word = HANDAX, word = HGNDGX.
INSPECT word TALLYING count FOR CHARACTERS AFTER INITIAL “J” REPLACING ALL “A”
BY “B”.
Where word = ADJECTIVE, count = 6 and word = BDJECTIVE.
Where word = JACK, count = 3 and word = JBCK.
Where word = JUJMAB, count = 5 and word = JUJMBB.
INSPECT word REPLACING ALL “X” BY “Y”, “B” BY “Z”, “W” BY “Q” AFTER INITIAL
“R”.
Where word = RXXBQWY, word = RYYZQQY.
Where word = YZACDWBR, word = YZACDWZR.
Where word = RAWRXEB, word = RAQRYEZ.
INSPECT word REPLACING CHARACTERS BY “B” BEFORE INITIAL “A”.
word before: 1 2 X Z A B C D
word after: B B B B B A B C D

How COBOL FLAT files(Index,Sequential) are very secure for huge data?If not, How will you migrate with any Database with Frond end COBOL?

How COBOL FLAT files(Index,Sequential) are very secure for huge data?If not, How will you migrate with any Database with Frond end COBOL?

Well if you are using flat file you have advantage as well as disadvantages.
Advantage -It is Secure Physically edited.
Disadvantage - Logically speaking performance is slow difficult to find the particular record.

Give simple program example for Dynamic link and Dynamic call in COBOL?

Static Call In Cobol:

Is calling of a literal.

CALL 'ABC' USING ARGUMENTS

The call statement specifies the sub-routine called as a literal. i.e, within quotes 'ABC'.
In static calls, if ABC is modified and recompiled, then all the executables calling ABC should be relinked.

Dynamic Calls:

01 Sub-Routine pic x(8) value 'ABC'

CALL ABC USING ARGUMENTS

Dynamic calling invovles calling a sub-routine using a variable and the variable contains the sub-routine name.
here the complied code is loaded when needed and is not incorporated into the executable.

What are the four divisions in COBOL

In Cobol there are 4 divisions.

1. Identification division or ID divisionIn this no setions are there. It has 5 paragraphs.
a. Progaram-id. programname
b. Author
c. Writen-date
d. Compiled-date
e. Installer

2. Environment Division
Under this there are two sub-sections
a. Configuration-section.
Source compter.
Object computer.
b. Input-Output section.
File control.
IO control.

3. Data DivisionFile-section.
Working-storage section.
Linkage section.
Report section.
Screen section.

4. Procedure Division

Explain the difference between an internal and an external sort, the pros and cons, internal sort syntax

Explain the difference between an internal and an external sort, the pros and cons, internal sort syntax etc? 
An external sort is not COBOL; it is performed through JCL and PGM=SORT. It is understandable without any code reference. An internal sort can use two different syntaxes: 1.) USING, GIVING sorts are comparable to external sorts with no extra file processing; 2) INPUT PROCEDURE, OUTPUT PROCEDURE sorts allow for data manipulation before and/or after the sort. 

Answer:
1. Internal sort is used in COBOL application prog while external sort is used in JCL.

2. Internal sort uses workfiles while external sort uses the DFSORT mechanism.

3. External sort is more complicated than internal sort.

4. Internal sort is more flexible as we can alter or update data before  and after performing internal sort whereas the same doesn't hold true for external sort.

IBM Mainframes : COBOL Interview Questions and Answers

File Concept 
The Disposition Parameter in the JCL is Share ( DISP=SHR ) and Cobol program opens file in " Extend " mode. In this scenarion what will happen to that file?

If we open file in xtend mode then old data will not lose we append the new data without losing old data.

IBM Mainframes: COBOL Interview Questions,

INSEPCT 
Give example of Inspect TALLYING / BEFORE INTIAL / AFTER INITIAL. In which situation will use this in COBOL?
01 my_string pic x(30) value 'mainframeinterviews'.
we can have operations on the string like
inspect my_string tallying tally_ct for all e before intial s and after intial i.
inspect my_string replacing all e by r before intal s and after intial i.

IBM Mainframes Interiew Questions and Answers-COBOL Interview Questions

Question:what will happen if i give program name and member name as 
different? program runs successful or w'll abend?
 Answer: 
The program will be compiled successfully and the load willbe created with the member name only. 
So, no issues withprogram name and member name being different.

(a)//COMPILE.SYSIN  DD  DSN=OZA093.SUNIL.COBO1(DATE),DISP=SHR
(b)//LKED.SYSLMOD   DD
DSN=OZA093.SUNIL.LOADLIB(DATE),DISP=SHR    

here (a) is for compilation.and (b) is for
execution.i.e.loadmodule of our program. after compilation
of our program.the compiler will generate an object code to
our program. this only going to be executed..what ever u
give at 
LOADLIB(DATE)..this name (for my program loadmodule name is
date) should be specified at 
//step  exec pgm=loadmodulename.(here date)

How can you pass values from COBOL program to non-COBOL programs

If u want to pass values from jcl to cobol use "parm" parameter in the exec statement and in the cobol program declare the linkage section for the values to be passed.If u want to pass values from cobol to other non-cobol programs this can be done by call by reference or call by value.ex: call pgma using ws-name, ws-sex.