Q1
Explain REDEFINES clause with an example.
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.
Q2
What is the difference between PARM and SYSIN for passing parameters?
PARM (EXEC statement):
- Limited to 100 characters
- Passed in memory to program
- Accessed via LINKAGE SECTION
- Good for small, simple parameters
SYSIN (DD statement):
- No practical size limit
- Read as a file by program
- Can contain multiple records
- Good for control cards, complex input
// PARM example //STEP1 EXEC PGM=MYPROG,PARM='PARAM1,PARAM2' // SYSIN example //SYSIN DD * CONTROL OPTION1 DATE=20231215 LIMIT=1000 /*
Q3
Explain the difference between INNER JOIN and LEFT OUTER JOIN.
INNER JOIN:
- Returns only matching rows from both tables
- If no match, row is excluded
LEFT OUTER JOIN:
- Returns all rows from left table
- Matching rows from right table
- NULL for right table if no match
-- INNER JOIN SELECT E.NAME, D.DEPT_NAME FROM EMPLOYEE E INNER JOIN DEPARTMENT D ON E.DEPT_ID = D.DEPT_ID; -- LEFT OUTER JOIN SELECT E.NAME, D.DEPT_NAME FROM EMPLOYEE E LEFT OUTER JOIN DEPARTMENT D ON E.DEPT_ID = D.DEPT_ID;
Use LEFT JOIN when you want all employees even those without department.
Q4
What is the purpose of COMMAREA in CICS?
COMMAREA (Communication Area) is used to pass data between programs or between transactions in pseudo-conversational programming.
Uses:
- Pass data between LINK/XCTL programs
- Save data between pseudo-conversational transactions
- Maximum size: 32KB
How it works:
- Calling program: COMMAREA option on LINK/XCTL/RETURN
- Called program: DFHCOMMAREA in LINKAGE SECTION
- Check EIBCALEN for length (0 = no COMMAREA)
* Calling program
EXEC CICS LINK
PROGRAM('SUBPROG')
COMMAREA(WS-DATA)
LENGTH(100)
END-EXEC.
* Called program
LINKAGE SECTION.
01 DFHCOMMAREA PIC X(100).
IF EIBCALEN > 0
MOVE DFHCOMMAREA TO WS-DATA
END-IF.
Q5
What is the difference between WORKING-STORAGE and LOCAL-STORAGE?
WORKING-STORAGE is allocated once at program load and persists across calls. LOCAL-STORAGE is allocated fresh each time the program is called and initialized each invocation. Use LOCAL-STORAGE for reentrant programs.
Q6
What is REDEFINES and what are its restrictions?
REDEFINES allows multiple data descriptions for same memory location. Restrictions: Cannot redefine with larger size, must be at same level, cannot use VALUE with REDEFINES target, occurs-depending cannot be redefined.
Q7
What is FILE STATUS and how to use it?
FILE STATUS is 2-byte field capturing I/O results. Declare in SELECT, check after each I/O. Common codes: 00=success, 10=EOF, 22=duplicate, 23=not found, 35=not exists, 39=mismatch.
Q8
How do you handle S0C7 abend?
S0C7 is data exception - non-numeric in numeric field. Debug: Check OFFSET in dump, review initialization, validate input data, check REDEFINES, examine hex dump for invalid bytes in COMP-3 fields.
Q9
Explain STRING and UNSTRING verbs.
STRING concatenates: STRING f1 DELIMITED BY SPACE f2 INTO output. UNSTRING splits: UNSTRING input DELIMITED BY ',' INTO f1 f2. POINTER tracks position, OVERFLOW handles errors, TALLYING counts fields.
Q10
What is OCCURS DEPENDING ON?
ODO creates variable-length tables. 05 TABLE OCCURS 1 TO 100 DEPENDING ON WS-COUNT. Table size varies based on counter. Used with variable-length records. Only variable portion at end of record.
Q11
Explain reference modification.
Reference modification extracts substring: WS-FIELD(start:length). Example: WS-NAME(1:3) gets first 3 chars. Start is 1-based. Length optional (to end). Works with MOVE, IF, DISPLAY.
Q12
What is CORRESPONDING option?
MOVE CORRESPONDING moves fields with matching names between groups. ADD CORRESPONDING/SUBTRACT CORRESPONDING for arithmetic. Convenient but use carefully - silent partial moves if names don't match exactly.
Q13
How does SORT work in COBOL?
SORT verb: SORT sort-file ON ASCENDING KEY key-field USING input-file GIVING output-file. INPUT/OUTPUT PROCEDURE allows processing during sort. RELEASE adds to sort, RETURN retrieves.
Q14
Explain CALL BY REFERENCE vs BY CONTENT vs BY VALUE.
BY REFERENCE: Passes address, changes visible to caller. BY CONTENT: Passes copy, original unchanged. BY VALUE: Passes value for C interop. Default is BY REFERENCE.
Q15
What is STEPLIB vs JOBLIB?
JOBLIB at job level provides libraries for all steps. STEPLIB at step level overrides JOBLIB for that step. Both searched before LINKLIST. Can concatenate multiple libraries.
Q16
Explain GDG (Generation Data Groups).
GDG maintains dataset versions. Define base with IDCAMS. Reference: (+1)=new, (0)=current, (-1)=previous. LIMIT controls kept generations. Useful for backup/archive strategies.
Q17
How to pass data between job steps?
DISP=PASS passes datasets between steps. Symbolic parameters carry values. GDG relative references. Temporary datasets (&&) auto-pass. JCL symbols set by SET statement.
Q18
What causes S0C7 in batch?
S0C7 is data exception - non-numeric in numeric field. Check: input file data, variable initialization, REDEFINES usage, field alignment. Find OFFSET in dump.
Q19
How does SORT utility work?
SORT FIELDS=(position,length,format,order). Input: SORTIN. Output: SORTOUT. Control: SYSIN. Options: INCLUDE/OMIT for filtering, OUTREC/INREC for reformatting.
Q20
What is IDCAMS and common commands?
IDCAMS manages VSAM and catalogs. Commands: DEFINE CLUSTER, DELETE, REPRO (copy), LISTCAT (list), ALTER, VERIFY, PRINT. IF/THEN/ELSE for conditional logic.
Q21
How to create and reference procedures?
PROC defines procedure, PEND ends it. Store in PROCLIB. Reference: EXEC procname or EXEC PROC=procname. Override: //procstep.ddname DD overrides.
Q22
Explain OUTPUT statement.
OUTPUT defines SYSOUT characteristics. //OUT1 OUTPUT CLASS=A,COPIES=2. Reference: SYSOUT=*,OUTPUT=*.OUT1. Centralizes output specifications.
Q23
What is SMS (Storage Management)?
SMS automates storage management. DATACLAS defines data attributes, STORCLAS controls placement, MGMTCLAS defines retention. ACS routines assign classes automatically.
Q24
What is JCLLIB ORDER?
JCLLIB ORDER specifies procedure library search order. Must be before first EXEC. Takes precedence over system proclibs.
Q25
Explain COND parameter logic.
COND skips step IF condition is TRUE. COND=(4,LT) skips if 4 < any prior RC. COND=(0,NE) skips unless all prior steps returned 0. Use IF for clarity.
Q26
What is EXPLAIN and how to use it?
EXPLAIN analyzes query access path. Results in PLAN_TABLE. Shows index usage, join method, sort operations. Review ACCESSTYPE, MATCHCOLS for tuning.
Q27
What causes -811 SQLCODE?
SELECT INTO returned multiple rows when expecting one. Solutions: Add WHERE for single row, use MAX/MIN, declare cursor for multiple rows.
Q28
Explain DB2 isolation levels.
UR: Uncommitted read (dirty read OK). CS: Cursor stability (current row locked). RS: Read stability (accessed rows locked). RR: Repeatable read (range locked, no phantom).
Q29
What is RUNSTATS and when to run it?
RUNSTATS collects statistics for optimizer. Run after significant data changes. Updates SYSTABLES, SYSINDEXES. Critical for optimal access path selection.
Q30
What is DB2 plan vs package?
Plan is bound executable SQL. Package is independent SQL unit. Modern approach: packages in collections with small plans. Packages allow separate rebind.
Q31
Explain -911 SQLCODE handling.
Deadlock or timeout. Two processes waiting for each other. Solutions: Retry transaction, consistent lock order, shorter transactions, appropriate isolation level.
Q32
What is REBIND and when needed?
REBIND updates access path without precompile. After RUNSTATS, index changes, performance issues. Can improve or degrade - test first.
Q33
Explain buffer pool importance.
Buffer pool caches data/index pages. Hit ratio critical. GETPAGE vs SYNCIO shows effectiveness. Size appropriately for workload.
Q34
Explain CI and CA in VSAM.
CI (Control Interval): I/O unit containing records and control info. CA (Control Area): Group of CIs. CI split on insert, CA split more expensive.
Q35
What is SHAREOPTIONS parameter?
SHAREOPTIONS(crossregion,crosssystem). 1=exclusive, 2=read share/write exclusive, 3=full sharing, 4=full sharing no refresh. Affects concurrent access.
Q36
How does alternate index work?
AIX provides secondary access path. DEFINE AIX, DEFINE PATH, BLDINDEX to build. UPGRADE maintains automatically. Access via PATH, not AIX directly.
Q37
What is FREESPACE parameter?
FREESPACE(CI%,CA%). CI% free for inserts within CI. CA% free for CI splits. More freespace reduces splits but uses space.
Q38
What is VERIFY utility?
VERIFY corrects catalog end-of-data after abend. Run before processing if previous job abended without proper CLOSE.
Q39
What is RBA?
RBA (Relative Byte Address) is byte offset from start. ESDS uses RBA for access. Changed by REORG. Use key for KSDS when possible.
Q40
How does BROWSE work?
STARTBR positions cursor. READNEXT/READPREV retrieves records. ENDBR ends browse. TOKEN for concurrent browses. Can use generic key.
Q41
What is file status 97?
VSAM OPEN error. Check: SHAREOPTIONS, file status, competing access, damaged cluster. Run VERIFY if needed.
Q42
Explain BUFND and BUFNI.
BUFND: data buffers. BUFNI: index buffers. More buffers improve performance but use memory. Tune based on access pattern.
Q43
How to handle CICS RESP codes?
EXEC CICS command RESP(ws-resp). Check DFHRESP(NORMAL) for success. RESP2 has additional info. Always check after commands.
Q44
What is START command?
START schedules future transaction. EXEC CICS START TRANSID(trans) INTERVAL(time) FROM(data). Used for background processing.
Q45
How does BROWSE work in CICS?
STARTBR positions, READNEXT/READPREV retrieves, ENDBR ends. TOKEN for concurrent browses. Use for sequential VSAM access.
Q46
What is temporary storage?
TS queue stores data across tasks. WRITEQ TS writes, READQ TS reads, DELETEQ removes. MAIN (memory) or AUXILIARY (disk).
Q47
Explain HANDLE CONDITION.
Sets error labels: HANDLE CONDITION NOTFND(para). Jumps on condition. Obsolete - prefer RESP option for cleaner handling.
Q48
What causes ASRA abend?
Program check (S0Cx) in CICS. Common: S0C7 data exception, S0C4 protection. Check CEDF, examine dump for cause.
Q49
What is CEDA?
CEDA defines resources online. CEDA DEFINE PROGRAM/TRANSACTION/FILE. CEDA INSTALL activates. RDO (Resource Definition Online).
Q50
Explain transient data.
TD queues for sequential I/O. Intrapartition: CICS internal. Extrapartition: external datasets. Defined in DCT. Trigger level for automatic transaction start.
Q51
What is SYNCPOINT?
SYNCPOINT commits changes. SYNCPOINT ROLLBACK undoes since last sync. Use for transaction consistency. Implicit at task end.