IBM COBOL Job Interview Questions and Answers

9/24/2009 No Comment

IBM COBOL Job Interview Questions and Answers.

What is the difference between COMP & COMP-3 ?
Answer : COMP is a binary storage format while COMP-3 is packed decimal format.

What is COMP-1 and COMP-2? 
Answer : COMP-1 - Single precision floating point. Uses 4 bytes. COMP-2 - Double precision floating point. Uses 8 bytes.

How do you define a variable of COMP-1? COMP-2?
Answer : No picture clause to be given. Example 01 WS-VAR USAGE COMP-1.

How many bytes does a S9(7) COMP-3 field occupy ?
Answer : Will take 4 bytes. Sign is stored as hex value in the last nibble.
General formula is INT((n/2) + 1)), where n=7 in this example.

How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy ?

Answer : Will occupy 8 bytes (one extra byte for sign).

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

Answer : In COBOL II: 16777215

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 comp field is faster.

How do you reference the following file formats from COBOL programs?

Answer : 
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. i.e. JCL record length will be max record length in program + 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? In which modes are the files Opened to write.

Answer : Different Open modes for files are INPUT, OUTPUT, I-O and EXTEND. Of which Output and Extend modes are used to write new records into a file.

In the JCL, how do you define the files referred to in a subroutine?

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

Answer : Can rewrite(record length must be same), but not delete.

What is file status 92?

Answer : Logic error. e.g., a file is opened for input and an attempt is made to write to it.

What is file status 39?

Answer : 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, Dynamic linking ?

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

Explain NEXT and CONTINUE verbs for file handling.

Answer : A The Continue verb is used for a situation where there in no EOF condition. i.e. The records are to be accessed again and again in a file. Whereas in the next verb the indexed file is accessed sequentially, whence when index clause is accessed sequentially read next record command is used.

What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY)? (applicable to only MVS/ESA).
Answer : These are compile/link edit options. AMODE - Addressing mode. RMODE - 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?

Answer : DYNAM.

What is SSRANGE, NOSSRANGE ?

Answer : These are compiler options w.r.t 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?

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

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

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

Answer : 
1. 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 allowing program to address above 16 Meg main storage line.
2. Report writer is supported only in OS/VS Cobol.
3. USAGE IS POINTER is supported only in VS COBOL II.
4. Reference modification eg: WS-VAR(1:2) is supported only in VS COBOL II.
5. COBOL II introduces new features (EVALUATE, SET ... TO TRUE, CALL ... BY CONTEXT, etc)
6. Scope terminators are supported in COBOL II.
7. OS/VS Cobol follows ANSI 74 stds while VS COBOL II follows ANSI 85 stds.
8. Under CICS Calls between VS COBOL II programs are supported.
9. COBOL II supports structured programming by using in-line PERFORM 's.
10. COBOL II does not support old features (READY TRACE, REPORT-WRITER, ISAM, etc.).
11. In non-CICS environment, it is possible. In CICS, this is not possible.
Related Posts


No comments :

 

Aired | The content is copyrighted and may not be reproduced on other websites. | Copyright © 2009-2016 | All Rights Reserved 2016

Contact Us | About Us | Privacy Policy and Disclaimer