👁 0
Q: What is GLOBAL clause?
Answer:
GLOBAL makes data available to nested programs. 01 WS-COUNTER PIC 9(5) GLOBAL. Nested programs can reference without passing as parameters. Use sparingly; explicit passing preferred. File definitions can also be GLOBAL.
👁 0
Q: What is file status 41?
Answer:
Status 41 is file already open. Duplicate OPEN attempted. Check program flow. CLOSE before re-OPEN. May be logic error in nested calls. STATUS after OPEN shows this.
👁 0
Q: Explain PERFORM VARYING with example
Answer:
PERFORM VARYING executes a paragraph while incrementing a counter. Syntax: PERFORM para-name VARYING WS-IDX FROM 1 BY 1 UNTIL WS-IDX > 10. The counter is initialized, tested, and incremented automatically. Can have nested VARYING with AFTER clause.
👁 0
Q: What is EVALUATE statement and when to use it?
Answer:
EVALUATE is COBOL's case/switch construct. Syntax: EVALUATE TRUE WHEN condition-1 statement WHEN OTHER default END-EVALUATE. More readable than nested IF for multiple conditions. Can evaluate multiple subjects and use THRU for ranges.
👁 0
Q: What are nested programs?
Answer:
Nested programs are contained within another COBOL program. Defined between IDENTIFICATION DIVISION and END PROGRAM. Can access outer program's data with GLOBAL clause. COMMON attribute allows access from sibling programs. Promotes modular design.
👁 0
Q: Explain access path selection
Answer:
Optimizer chooses access path based on statistics, predicates, indexes. Index scan vs tablespace scan. Join methods: nested loop, merge scan, hybrid. Sort operations. EXPLAIN reveals choice. Tuning influences path.
👁 0
Q: How to use PUSH/POP HANDLE?
Answer:
PUSH HANDLE saves current handlers. POP HANDLE restores. EXEC CICS PUSH HANDLE. Allows nested handler management. Clean up with POP. For modular code.