Q1
What are the four divisions of a COBOL program?
- 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.
Q2
What is the difference between SECTION and PARAGRAPH in COBOL?
SECTION:
- Contains one or more paragraphs
- Ends with next SECTION or end of program
- Used for logical grouping
- Can be performed as a unit
PARAGRAPH:
- Basic unit of code
- Named block of statements
- Ends at next paragraph name or SECTION
PERFORM SECTION-NAME executes all paragraphs in the section.
PERFORM PARA-NAME executes only that paragraph.
Q3
What is a copybook and why is it used?
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
Q4
What is SQLCODE and what are common values?
SQLCODE is a return code in SQLCA indicating the result of SQL execution.
Common SQLCODE values:
| 0 | Successful execution |
| 100 | No data found / End of cursor |
| -803 | Duplicate key on insert |
| -811 | Multiple rows returned for singleton SELECT |
| -904 | Unavailable resource |
| -911 | Deadlock/timeout |
| -922 | Authorization failure |
| -927 | DB2 not available |
Negative = Error, 0 = Success, 100 = No data
Q5
Explain the four divisions of a COBOL program.
IDENTIFICATION DIVISION: Program identification (PROGRAM-ID required). ENVIRONMENT DIVISION: Hardware/software configuration, file definitions. DATA DIVISION: Variable declarations, file records, working storage. PROCEDURE DIVISION: Executable code, business logic.
Q6
Explain COMP, COMP-1, COMP-2, and COMP-3 data types.
COMP: Binary (2/4/8 bytes based on PIC). COMP-1: Single precision floating point (4 bytes). COMP-2: Double precision floating point (8 bytes). COMP-3: Packed decimal (2 digits per byte + sign nibble).
Q7
How does SEARCH differ from SEARCH ALL?
SEARCH: Sequential search from current index position. SEARCH ALL: Binary search requiring sorted table with KEY clause. SEARCH ALL is faster for large tables but requires sorted data and indexed table.
Q8
What is COPY statement and how does REPLACING work?
COPY includes copybook at compile time. REPLACING substitutes text: COPY copybook REPLACING ==OLD== BY ==NEW==. Used for code reuse and standardization across programs.
Q9
Explain the PERFORM verb variations.
PERFORM para: Execute once. PERFORM para THRU para-exit: Execute range. PERFORM para n TIMES: Execute n times. PERFORM para UNTIL condition: Loop until true. PERFORM VARYING: Counter-controlled loop.
Q10
What is EVALUATE statement and its advantages?
EVALUATE is COBOL's case construct. EVALUATE TRUE WHEN condition-1 action WHEN OTHER default. Cleaner than nested IF, can evaluate multiple subjects, supports ALSO for multiple conditions, uses THRU for ranges.
Q11
What is INITIALIZE and what doesn't it initialize?
INITIALIZE sets fields to defaults: alphabetic to SPACES, numeric to ZEROS. Does NOT initialize: FILLER items, REDEFINES items, index data items. Can use REPLACING for custom values.
Q12
What is the purpose of LINKAGE SECTION?
LINKAGE SECTION defines parameters received from calling program. Items have no memory until CALL provides addresses. Used for passed parameters and dynamically addressed data.
Q13
What is GOBACK vs STOP RUN?
STOP RUN terminates entire run unit. GOBACK returns to caller; if main, acts like STOP RUN. Always use GOBACK in subprograms. STOP RUN from subprogram terminates everything.
Q14
Explain the difference between COND and IF/THEN/ELSE.
COND tests return codes to SKIP steps (negative logic). IF/THEN/ELSE tests conditions to EXECUTE steps (positive logic). IF supports complex expressions. COND on JOB affects all steps, on EXEC affects that step.
Q15
How does DISP parameter work?
DISP=(status,normal,abnormal). Status: NEW/OLD/SHR/MOD. Normal disposition after success. Abnormal after abend. Example: DISP=(NEW,CATLG,DELETE) creates, catalogs if OK, deletes if abend.
Q16
What does TYPRUN=SCAN do?
TYPRUN=SCAN validates JCL syntax without execution. No resources allocated, no programs run. Checks for errors before production submission.
Q17
Explain SPACE parameter options.
SPACE=(unit,(primary,secondary,directory)). Units: TRK/CYL/blocksize. Directory for PDS. Options: RLSE (release unused), CONTIG (contiguous), ROUND (round to cylinder).
Q18
What is DD DUMMY?
DD DUMMY discards output, provides EOF for input. No I/O actually performed. Equivalent: DSN=NULLFILE. Used for testing or optional files.
Q19
Explain REGION parameter.
REGION specifies memory limit. REGION=0M means system default (no limit). REGION=4M limits to 4MB. On JOB affects all steps, on EXEC affects that step.
Q20
What is DD * vs DD DATA?
DD * starts instream data ending with /*. DD DATA allows DLM=xx for custom delimiter when data contains /*. DD DATA,DLM=@@ ends with @@.
Q21
What is NOTIFY parameter?
NOTIFY=userid sends completion message. NOTIFY=&SYSUID notifies submitter. Multiple: NOTIFY=(user1,user2). Essential for batch monitoring.
Q22
How does IEFBR14 work?
IEFBR14 is null program (Branch Register 14 = return). Used for dataset management: create, delete, catalog. Example: //DEL EXEC PGM=IEFBR14 //DD DD DSN=file,DISP=(MOD,DELETE).
Q23
What is SQLCODE and common values?
SQLCODE indicates SQL result. 0=success, 100=not found/EOF, negative=error. Common: -803 duplicate key, -811 multiple rows, -904 unavailable, -911 deadlock, -818 timestamp mismatch.
Q24
Explain INNER JOIN vs LEFT OUTER JOIN.
INNER returns only matching rows. LEFT OUTER returns all left rows plus matching right (NULL if no match). LEFT preserves all left table rows.
Q25
How to handle NULL values?
NULL means unknown/missing. Use IS NULL/IS NOT NULL. COALESCE(col,default) substitutes. Indicator variables in COBOL detect NULL. NVL alternative function.
Q26
How does cursor work?
DECLARE defines cursor. OPEN executes SELECT. FETCH retrieves rows. CLOSE releases resources. FOR UPDATE allows positioned UPDATE/DELETE. WITH HOLD survives COMMIT.
Q27
What is indicator variable?
Indicator detects NULL. Declare: 01 VAR-IND PIC S9(4) COMP. Use: INTO :VAR:VAR-IND. Negative means NULL. Required for nullable columns.
Q28
How does COMMIT work?
COMMIT makes changes permanent, releases locks. ROLLBACK undoes changes. Implicit COMMIT at program end. Frequent COMMIT reduces lock duration.
Q29
What are KSDS, ESDS, RRDS, and LDS?
KSDS: Key sequenced, unique key, random/sequential access. ESDS: Entry sequenced, no key, RBA access. RRDS: Relative record, slot number access. LDS: Linear, byte stream.
Q30
What causes file status 23?
Record not found for READ/START/DELETE. Key doesn't exist. Verify key value, handle not-found condition in program logic.
Q31
Explain REPRO utility.
REPRO copies VSAM files. Can copy between VSAM and sequential. Options: FROMKEY/TOKEY, SKIP/COUNT, REPLACE. Used for backup, conversion.
Q32
How to handle file status 35?
File not found. Check: DSN spelling, catalog entry exists, file created. Add DD statement if missing.
Q33
Explain KSDS key definition.
KEYS(length offset). Length up to 255. Offset from position 0. Key extracted from record. Must be unique. Alphanumeric comparison.
Q34
What causes file status 22?
Duplicate key on WRITE. KSDS primary key must be unique. Check data, use REWRITE for updates instead.
Q35
What is pseudo-conversational programming?
Transaction ends after SEND, restarts on input. RETURN TRANSID(next) COMMAREA(data). Saves resources - no task waiting. Must restore state from COMMAREA.
Q36
Explain COMMAREA usage.
COMMAREA passes data between programs and transactions. Max 32KB. LINK/XCTL COMMAREA(data). Receiving program has DFHCOMMAREA in LINKAGE SECTION.
Q37
What is LINK vs XCTL?
LINK calls and returns to caller (like CALL). XCTL transfers permanently, no return. Use LINK for subroutines, XCTL for navigation.
Q38
What is BMS?
Basic Mapping Support handles screen I/O. DFHMSD defines mapset. SEND MAP displays. RECEIVE MAP gets input. Symbolic map in COBOL copybook.
Q39
Explain EIB fields.
EIB (Execute Interface Block): EIBCALEN=COMMAREA length, EIBTRNID=transaction, EIBAID=attention key, EIBRESP=response code. Available automatically.
Q40
How to debug CICS programs?
CEDF intercepts EXEC CICS. Step through commands, view/modify data. CEMT for resource status. Transaction dump for abends.