DB2 Packages and Plan

Assume PROG A Calling PROG B, C and PROG C calling D and E, Here how many PACKAGES and PLAN will be created? 
Answer : There will be a DB2 Package for every program and only one Plan

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 2

11. What should be the sorting order for SEARCH ALL?
It can be either ASCENDING or DESCENDING. ASCENDING is default. If you want the search to be done on an array sorted in descending order, then while defining the array, you should give DESCENDING KEY clause. (You must load the table in the specified order).
12. What is binary search?
Search on a sorted array. Compare the item to be searched with the item at the center. If it matches, fine else repeat the process with the left half or the right half depending on where the item lies.
13. 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?
Must use compiler option SSRANGE if you want array bounds checking. Default is NOSSRANGE.
14. How do you sort in a COBOL program? Give sort file definition, sort statement syntax and meaning.
Syntax:
SORT file-1 ON ASCENDING/DESCENDING KEY key....
USING file-2
GIVING file-3.
USING can be substituted by INPUT PROCEDURE IS para-1 THRU para-2
GIVING can be substituted by OUTPUT PROCEDURE IS para-1 THRU para-2.
file-1 is the sort workfile and must be described using SD entry in FILE SECTION.
file-2 is the input file for the SORT and must be described using an FD entry in FILE SECTION and SELECT clause in FILE CONTROL.
file-3 is the outfile from the SORT and must be described using an FD entry in FILE SECTION and SELECT clause in FILE CONTROL.
file-1, file-2 & file-3 should not be opened explicitly.
INPUT PROCEDURE is executed before the sort and records must be RELEASEd to the sort work file from the input procedure.
OUTPUT PROCEDURE is executed after all records have been sorted. Records from the sort work file must be RETURNed one at a time to the output procedure.
15. How do you define a sort file in JCL that runs the COBOL program?
Use the SORTWK01, SORTWK02,..... dd names in the step. Number of sort datasets depends on the volume of data being sorted, but a minimum of 3 is required.
16. What are the two ways of doing sorting in a COBOL program? Give the formats.
See question 17.
 
17. Give the format of USING and GIVING in SORT statement. What are the restrictions with it?
See question 16. Restrictions - Cannot massage records, canot select records to be sorted.
18. What is the difference between performing a SECTION and a PARAGRAPH?
Performing a SECTION will cause all the paragraphs that are part of the section, to be performed.
Performing a PARAGRAPH will cause only that paragraph to be performed.
19. What is the use of EVALUATE statement?
Evaluate is like a case statement and can be used to replace nested Ifs. The difference between EVALUATE and case is that no 'break' is required for EVALUATE i.e. control comes out of the EVALUATE as soon as one match is made.
20. What are the different forms of EVALUATE statement?
EVALUATE EVALUATE SQLCODE ALSO FILE-STATUS
WHEN A=B AND C=D WHEN 100 ALSO '00'
imperative stmt imperative stmt
WHEN (D+X)/Y = 4 WHEN -305 ALSO '32'
imperative stmt imperative stmt
WHEN OTHER WHEN OTHER
imperative stmt imperative stmt
END-EVALUATE END-EVALUATE
EVALUATE SQLCODE ALSO A=B EVALUATE SQLCODE ALSO TRUE
WHEN 100 ALSO TRUE WHEN 100 ALSO A=B
imperative stmt imperative stmt
WHEN -305 ALSO FALSE WHEN -305 ALSO (A/C=4)
imperative stmt imperative stmt
END-EVALUATE END-EVALUATE

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.

Mainframes Architecture

http://www.energyideas.ca/img/mainframe.JPG
Mainframes Architecture

Mainframe vs. Client/Server

In a client/server architecture, multiple computers typically cooperate to do the same task. For example, in Figure 1.1 the application uses a Web server, a database server, and an LDAP server.
Figure 1.1 Figure 1.1 Client/server architecture
On a mainframe, the same computer does everything. One security package (RACF, in most cases) protects one operating system kernel. Mainframe subsystems do everything else, as you can see in Figure 1.2.
That's a little of the "why" of mainframes. Now let's get started with the "how."

Introduction to Mainframe Basics for Security Professionals

1.1 Why Use a Mainframe?

Where do mainframes fit in? The mainframes we use today date back to April 7, 1964, with the announcement of the IBM System/360™. System/360 was a revolutionary step in the development of the computer for many reasons, including these:
  • System/360 could do both numerically intensive scientific computing and input/output intensive commercial computing.
  • System/360 was a line of upwardly compatible computers that allowed installations to move to more powerful computers without having to rewrite their programs.
  • System/360 utilized dedicated computers that managed the input/output operations, which allowed the central processing unit to focus its resources on the application.
These systems were short on memory and did not run nearly as fast as modern computers. For example, some models of the System/360 were run with 32K (yes, K, as in 1,024 bytes) of RAM, which had to accommodate both the application and the operating system. Hardware and software had to be optimized to make the best use of limited resources.