COBOL FAQs -- Part VI (MainFrame)
Home -- FAQs Home
A D V E R T I S E M E N T
1. Name the divisions in a COBOL program.
Ans:
IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION, PROCEDURE DIVISION.
2. What are the different data types available in COBOL?
Ans:
Alpha-numeric (X), alphabetic (A) and numeric (9).
3. What does the INITIALIZE verb do?
Ans:
Alphabetic, Alphanumeric fields & alphanumeric edited items are set to SPACES.
Numeric, Numeric edited items set to ZERO.
FILLER , OCCURS DEPENDING ON items left untouched.
4. What is 77 level used for ?
Ans:
Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves.
5. What is 88 level used for ?
Ans:
For condition names.
6. What is level 66 used for ?
Ans:
For RENAMES clause.
7. Can the OCCURS clause be at the 01 level?
Ans:
No.
8. What is the difference between SEARCH and SEARCH ALL? - GS
Ans:
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.
9. 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?
Ans:
Must use compiler option SSRANGE if you want array bounds checking. Default is NOSSRANGE.
10.What is the difference between CONTINUE & NEXT SENTENCE ?
Ans:
CONTINUE is like a null statement (do nothing) , while NEXT SENTENCE transfers control to the next sentence (!!) (A sentence is terminated by a period)
11.Can I redefine an X(100) field with a field of X(200)?
Ans:
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.
12.Can I redefine an X(200) field with a field of X(100) ?
Ans:
Yes.
13.How is sign stored in a comp-3 field? - GS
Ans:
It is stored in the last nibble. For example if your number is +100, it stores hex 0C in the last byte, hex 1C if your number is 101, hex 2C if your number is 102, hex 1D if the number is -101, hex 2D if the number is -102 etc...
14. How is sign stored in a COMP field ? - GS
Ans:
In the most significant bit. Bit is on if -ve, off if +ve.
15.What is the difference between COMP & COMP-3 ?
Ans:
COMP is a binary storage format while COMP-3 is packed decimal format.
16.What is COMP-1? COMP-2?
Ans:
COMP-1 - Single precision floating point. Uses 4 bytes.
COMP-2 - Double precision floating point. Uses 8 bytes.
17.How do you define a variable of COMP-1? COMP-2?
Ans:
No picture clause to be given. Example 01 WS-VAR USAGE COMP-1.
18.How many bytes does a S9(7) COMP-3 field occupy ?
Ans:
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.
19.What are different file OPEN modes available in COBOL?
Ans:
Open for INPUT, OUTPUT, I-O, EXTEND.
20.What is Static,Dynamic linking ?
Ans:
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.
21.What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY)? ( applicable to only MVS/ESA Enterprise Server).
Ans:
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.
22.What compiler option would you use for dynamic linking?
Ans:
DYNAM.
23.How do you set a return code to the JCL from a COBOL program?
Ans:
Move a value to RETURN-CODE register. RETURN-CODE should not be declared in your program.