👁 0
Q: What are the four divisions of a COBOL program?
Answer:
- IDENTIFICATION DIVISION - Program identification (PROGRAM-ID)
- ENVIRONMENT DIVISION - Hardware/software environment, file assignments
- DATA DIVISION - Data definitions (FILE, WORKING-STORAGE, LINKAGE SECTION)
- PROCEDURE DIVISION - Executable code and business logic
Only IDENTIFICATION and PROCEDURE DIVISION are mandatory.
👁 0
Q: Explain REDEFINES clause with an example.
Answer:
REDEFINES allows the same storage area to be referenced by different data names with different definitions.
Rules:
- Must be at same level as item being redefined
- Cannot redefine item with OCCURS
- Redefined item must appear first
- Lengths should match or redefining should be shorter
01 WS-DATE. 05 WS-DATE-NUM PIC 9(8). 01 WS-DATE-X REDEFINES WS-DATE. 05 WS-YEAR PIC 9(4). 05 WS-MONTH PIC 9(2). 05 WS-DAY PIC 9(2).
Same 8 bytes can be accessed as single number or individual components.
👁 0
Q: What is a copybook and why is it used?
Answer:
A copybook is a reusable code file that can be included in multiple programs using the COPY statement.
Uses:
- Standard record layouts
- Common working storage definitions
- Reusable paragraphs
- Ensures consistency across programs
Syntax:
COPY EMPREC. COPY EMPREC REPLACING ==EMP== BY ==WS-EMP==.
Benefits:
- Reduces code duplication
- Easier maintenance
- Standard definitions across team
👁 0
Q: Explain predicate types
Answer:
Stage 1 predicates evaluated by storage engine. Stage 2 evaluated by DB2 (more expensive). Indexable predicates can use index. Non-indexable force scan. Design for stage 1/indexable predicates. EXPLAIN shows predicate staging.
👁 0
Q: What is USAGE clause?
Answer:
USAGE specifies internal data representation. DISPLAY (default)=character, COMP/BINARY=binary, COMP-3/PACKED-DECIMAL=packed, COMP-1=single float, COMP-2=double float. Affects storage size and arithmetic performance.
👁 0
Q: What is tablespace?
Answer:
Tablespace is storage container for tables. CREATE TABLESPACE name IN database USING STOGROUP. Contains one or more tables. Segmented/universal tablespace types. Management at tablespace level (REORG, COPY, RECOVER).
👁 0
Q: What is XML support in DB2?
Answer:
DB2 stores XML natively. XMLTYPE column. XMLPARSE, XMLSERIALIZE for conversion. XQuery for querying. XMLTABLE extracts relational from XML. XML indexes for performance. Powerful for document storage.
👁 0
Q: Explain EXTERNAL clause
Answer:
EXTERNAL allows data sharing between separately compiled programs. 01 WS-SHARED PIC X(100) EXTERNAL. All programs with same EXTERNAL name share same storage. Use for global data without passing parameters. Be careful with initialization.
👁 0
Q: What is PERFORM recursion limit?
Answer:
COBOL doesn't traditionally support recursion; same paragraph in PERFORM stack causes error. RECURSIVE clause in PROGRAM-ID enables it. Recursive programs need local storage. Stack depth limited by system resources. Usually avoid in COBOL.
👁 0
Q: What is LOCAL-STORAGE SECTION?
Answer:
LOCAL-STORAGE SECTION is reinitialized each invocation. Unlike WORKING-STORAGE which retains values. Each thread gets own copy. Useful for recursive programs and threaded environments. COBOL-85+ feature. Not all compilers support equally.
👁 0
Q: How to handle binary data?
Answer:
COMP/BINARY stores binary. PIC S9(4) COMP is halfword (2 bytes). PIC S9(9) COMP is fullword (4 bytes). PIC S9(18) COMP is doubleword (8 bytes). SYNC aligns for performance. Value range limited by bytes, not picture.
👁 0
Q: How to compress VSAM?
Answer:
DFSMS compression via DATACLAS. Or EXTENDED FORMAT with compression. Not native VSAM feature. Reduces space, adds CPU overhead. Good for large, read-heavy files.
👁 0
Q: Explain SPACE parameter options
Answer:
SPACE=(unit,(primary,secondary,directory)). Unit: TRK/CYL/block-size. Primary allocated first, secondary in 15 increments. Directory only for PDS. RLSE releases unused. CONTIG requires contiguous. Example: SPACE=(CYL,(10,5,20),RLSE)
👁 0
Q: What is STORAGECLASS?
Answer:
SMS STORAGECLASS for VSAM placement. STORCLAS on DEFINE. Controls performance, availability. ACS routines may assign. Modern storage management. Replaces explicit volume specifications.
👁 0
Q: How to use temporary storage?
Answer:
TS queue stores data across tasks. EXEC CICS WRITEQ TS QUEUE(name) FROM(data). READQ retrieves. DELETEQ removes. ITEM number for multiple items. MAIN/AUXILIARY for storage type. Named by string.
👁 0
Q: How to handle SMS conversion?
Answer:
SMS manages storage automatically. Migrate VSAM to SMS: DATACLAS, STORCLAS, MGMTCLAS. ACS routines for assignment. Remove explicit VOL/UNIT. Benefits: automation, management.
👁 0
Q: What is the purpose of COPY statement?
Answer:
COPY includes copybook members at compile time, promoting code reuse and standardization. Syntax: COPY copybook-name. REPLACING clause allows field substitution. Copybooks typically contain record layouts, working-storage definitions, and common routines.
👁 0
Q: What is table compression?
Answer:
Compression reduces storage. Huffman encoding in dictionary. CREATE TABLE ... COMPRESS YES. REORG to compress existing. CPU trade-off for I/O savings. Good for read-heavy, large tables.
👁 0
Q: Explain host variable rules
Answer:
Host variables prefixed with : in SQL. Declare in WORKING-STORAGE. Must be compatible types. Use indicator for NULL. Cannot use in dynamic object names. VARCHAR needs two-part structure in COBOL.
👁 0
Q: Explain storage group
Answer:
Storage group defines volumes for data. CREATE STOGROUP name VOLUMES(vol1, vol2). Tablespaces assigned to stogroups. DB2 manages space within. PRIQTY/SECQTY control allocation. Foundation of storage management.
👁 0
Q: What is NATIVE-BCD?
Answer:
NATIVE-BCD is native binary-coded decimal, digits stored one per byte. Less efficient than COMP-3 but simpler to inspect in dumps. Some shops prefer for debugging. Available through compiler options or USAGE clause variations.
👁 0
Q: What is SERVICE RELOAD?
Answer:
SERVICE RELOAD refreshes segmented program overlays. Forces segment reload from disk. Rarely needed with virtual storage. From overlay management era. May affect performance. Better to restructure program than use frequently.
👁 0
Q: What is WORKING-STORAGE SECTION?
Answer:
WORKING-STORAGE SECTION declares program variables. Initialized at program load. Retains values between CALL invocations unless INITIAL program. Define all work areas, flags, counters, tables here. 01-49 levels for data, 77 for independent items.
👁 0
Q: Explain SMS-managed storage
Answer:
SMS (Storage Management Subsystem) manages dataset placement. Specify STORCLAS, MGMTCLAS, DATACLAS in DD. DATACLAS sets DCB attributes, STORCLAS controls placement, MGMTCLAS defines retention. SMS uses ACS routines for assignment.
👁 0
Q: What is GETMAIN?
Answer:
GETMAIN allocates temporary storage. EXEC CICS GETMAIN SET(pointer) LENGTH(size) INITIMG(X'00'). Returns pointer. Use for dynamic memory. FREEMAIN releases. SHARED for multi-task access. Automatic cleanup on task end.
👁 0
Q: What is DFSMS?
Answer:
DFSMS (Data Facility Storage Management Subsystem) automates storage management. Components: SMS, HSM (migration), DFRMM (tape). ACS routines assign classes. Reduces JCL complexity. DATACLAS defines data characteristics.
👁 0
Q: How to handle multivolume datasets?
Answer:
VOL=(,,,n) allows n volumes. SPACE with volume count. SMS handles multivolume automatically. DISP=MOD extends to new volume. DATACLAS can specify multivolume. Large datasets need multivolume planning.
👁 0
Q: Explain STORCLAS parameter?
Answer:
STORCLAS assigns SMS storage class. STORCLAS=classname. Determines placement, management, backup. ACS routines may assign. Defines performance characteristics. Installation-defined classes.
👁 0
Q: What is SQLCA structure?
Answer:
SQLCA (SQL Communication Area) contains execution results. SQLCODE for return code. SQLERRM for message. SQLERRD(3) for rows affected. SQLWARN for warnings. INCLUDE SQLCA in WORKING-STORAGE. Check after each SQL statement.