Wednesday, May 23, 2012

Cobol Interview Questions 3

What is the maximum value that can be stored in S9(8) COMP ?
99999999

What is COMP SYNC ?
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.

What is the maximum size of a 01 level item in COBOL I ? in COBOL II ?
In COBOL II: 16777215

How do you reference the following file formats from COBOL programs: ?
Fixed Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0.
Fixed Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, do not use BLOCK CONTAINS
Variable Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, BLOCK CONTAINS 0. Do not code the 4 bytes for record length in FD ie JCL rec length will be max rec length in pgm + 4
Variable Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, do not use BLOCK CONTAINS. Do not code 4 bytes for record length in FD ie JCL rec length will be max rec length in pgm + 4.
ESDS VSAM file - Use ORGANISATION IS SEQUENTIAL.
KSDS VSAM file - Use ORGANISATION IS INDEXED, RECORD KEY IS, ALTERNATE RECORD KEY IS .
RRDS File - Use ORGANISATION IS RELATIVE, RELATIVE KEY IS .
Printer File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0. (Use RECFM=FBA in JCL DCB).

What are different file OPEN modes available in COBOL ?
Open for INPUT, OUTPUT, I-O, EXTEND.

What is the mode in which you will OPEN a file for writing ?
OUTPUT, EXTEND

In the JCL, how do you define the files referred to in a subroutine ?
Supply the DD cards just as you would for files referred to in the main program.

Can you REWRITE a record in an ESDS file ? Can you DELETE a record from it ?
Can rewrite (record length must be same), but not delete.

What is file status 92 ?
Logic error. e.g., a file is opened for input and an attempt is made to write to it.

What is file status 39 ?
Mismatch in LRECL or BLOCKSIZE or RECFM between your COBOL pgm & the JCL (or the dataset label). You will get file status 39 on an OPEN.

What is Static and Dynamic linking ?
In static linking, the called subroutine is link-edited into the calling program , while in dynamic linking, the subroutine & the main program will exist as separate load modules.
You choose static/dynamic linking by choosing either the DYNAM or NODYNAM link edit option. (Even if you choose NODYNAM, a CALL identifier (as opposed to a CALL literal), will translate to a DYNAMIC call).
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.

What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY) ?
(applicable to only MVS/ESA Enterprise Server). These are compile/link edit options. Basically AMODE stands for Addressing mode and RMODE for Residency mode.
AMODE(24) - 24 bit addressing; AMODE(31) - 31 bit addressing.
AMODE(ANY) - Either 24 bit or 31 bit addressing depending on RMODE.
RMODE(24) - Resides in virtual storage below 16 Meg line. Use this for 31 bit programs that call 24 bit programs. (OS/VS Cobol pgms use 24 bit addresses only).
RMODE(ANY) - Can reside above or below 16 Meg line.

What compiler option would you use for dynamic linking ?
DYNAM.

What is SSRANGE, NOSSRANGE ?
These are compiler options with respect to subscript out of range checking. NOSSRANGE is the default and if chosen, no run time error will be flagged if your index or subscript goes out of the permissible range.

How do you set a return code to the JCL from a COBOL program ?
Move a value to RETURN-CODE register. RETURN-CODE should not be declared in your program.

How can you submit a job from COBOL programs ?
Write JCL cards to a dataset with //xxxxxxx SYSOUT= (A,INTRDR) where 'A' is output class, and dataset should be opened for output in the program. Define a 80 byte record layout for the file.

Q57) What are the differences between OS VS COBOL and VS COBOL II ?

Q57) OS/VS Cobol pgms can only run in 24 bit addressing mode, VS Cobol II pgms can run either in 24 bit or 31 bit addressing modes. I. Report writer is supported only in OS/VS Cobol. II. USAGE IS POINTER is supported only in VS COBOL II. III. Reference modification e.g.: WS-VAR(1:2) is supported only in VS COBOL II. IV. EVALUATE is supported only in VS COBOL II. V. Scope terminators are supported only in VS COBOL II. VI. OS/VS Cobol follows ANSI 74 stds while VS COBOL II follows ANSI 85 stds. VII. Under CICS Calls between VS COBOL II programs are supported.

Q58) What are the steps you go through while creating a COBOL program executable ?

Q58) DB2 precompiler (if embedded SQL used), CICS translator (if CICS pgm), Cobol compiler, Link editor. If DB2 program, create plan by binding the DBRMs.

Q59) Can you call an OS VS COBOL pgm from a VS COBOL II pgm ?

Q59) In non-CICS environment, it is possible. In CICS, this is not possible.

Q60) What are the differences between COBOL and COBOL II ?

A60) There are at least five differences: COBOL II supports structured programming by using in line Performs and explicit scope terminators, It introduces new features (EVALUATE, SET. TO TRUE, CALL. BY CONTEXT, etc) It permits programs to be loaded and addressed above the 16-megabyte line It does not support many old features (READY TRACE, REPORT-WRITER, ISAM, Etc.), and It offers enhanced CICS support.

No comments:

Post a Comment