Q: How do I fix S0C7 Data Exception ABEND?
S0C7 occurs when the program tries to perform arithmetic on non-numeric data.
Common Causes:
- Uninitialized numeric fields (contains spaces/garbage)
- Moving alphanumeric data to numeric field
- Reading file with wrong record layout
- Array subscript accessing wrong memory
How to Fix:
- Initialize all numeric fields to ZEROS
- Validate input before arithmetic
- Check file layouts match
- Use DISPLAY to debug field contents
* Always initialize
INITIALIZE WS-RECORD.
MOVE ZEROS TO WS-AMOUNT.
* Validate before use
IF WS-INPUT IS NUMERIC
COMPUTE WS-RESULT = WS-INPUT * 2
END-IF.
Q: What is the difference between COND and IF/THEN/ELSE in JCL?
COND Parameter:
- Tests return codes from previous steps
- Bypasses step if condition is TRUE
- Works opposite to programming logic!
- COND=(4,LT) means: Skip if 4 < any previous RC
IF/THEN/ELSE:
- More intuitive programming-like syntax
- Executes steps when condition is TRUE
- Supports AND, OR operators
- Can check ABEND conditions
Example:
// Using COND (skip if RC < 4) //STEP2 EXEC PGM=PROG2,COND=(4,LT) // Using IF/THEN/ELSE // IF STEP1.RC = 0 THEN //STEP2 EXEC PGM=PROG2 // ELSE //ERROR EXEC PGM=ERRPROC // ENDIF
Q: When should I use COMMIT in DB2?
COMMIT saves all changes since the last COMMIT and releases locks.
When to COMMIT:
- After processing a logical unit of work
- Periodically in long-running batch (every N records)
- Before ending the program successfully
Frequency Guidelines:
- Too frequent: Performance overhead
- Too rare: Lock contention, large log
- Typical: Every 100-1000 records in batch
Best Practice:
MOVE 0 TO WS-COMMIT-COUNT.
PERFORM PROCESS-RECORD.
ADD 1 TO WS-COMMIT-COUNT.
IF WS-COMMIT-COUNT >= 500
EXEC SQL COMMIT END-EXEC
MOVE 0 TO WS-COMMIT-COUNT
END-IF.
Note: In CICS, syncpoint (COMMIT) happens automatically at task end. Explicit SYNCPOINT is rarely needed.
Q: What is the difference between KSDS and ESDS?
KSDS (Key Sequenced Data Set):
- Records accessed by unique key
- Records stored in key sequence
- Has both data and index components
- Supports random and sequential access
- Can delete and reinsert records
- Most commonly used VSAM type
ESDS (Entry Sequenced Data Set):
- Records stored in arrival order
- Accessed by RBA (Relative Byte Address)
- No index component
- Cannot delete records (only mark inactive)
- Similar to sequential files
- Good for logs, audit trails
Use KSDS when: You need key-based access, updates, deletes
Use ESDS when: Sequential processing only, append-only data
Q: What is pseudo-conversational programming in CICS?
Pseudo-conversational programming is a technique where the program ends between user interactions, freeing system resources.
How it works:
- Program sends screen to user and ends (RETURN TRANSID)
- User enters data and presses Enter
- CICS starts a new task with same program
- Program retrieves saved data from COMMAREA
- Process continues
Benefits:
- Efficient resource usage
- Better response times
- More concurrent users
Implementation:
* End task, wait for user
EXEC CICS RETURN
TRANSID('MENU')
COMMAREA(WS-COMM)
LENGTH(100)
END-EXEC.
* On return, check EIBCALEN
IF EIBCALEN = 0
PERFORM FIRST-TIME
ELSE
MOVE DFHCOMMAREA TO WS-COMM
PERFORM PROCESS-INPUT
END-IF.
Q: 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.
Q: What is UDF (User Defined Function)?
Q: 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
Q: 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.