Chapter 41 Quiz: Capstone Project -- Building a Complete Banking Application
Test your understanding of the capstone banking application's architecture, design decisions, data flow, and component integration. Each question is followed by a hidden answer -- try to answer before revealing it.
Multiple Choice Questions
Question 1
In the capstone's data architecture, why is the customer master file stored as a VSAM KSDS rather than a DB2 table for the primary online lookup?
- a) VSAM is always faster than DB2 for every type of access
- b) VSAM KSDS provides efficient key-based direct access without SQL overhead, which is optimal for CICS single-record lookups
- c) DB2 cannot store records longer than 250 bytes
- d) VSAM files can be shared between CICS regions but DB2 tables cannot
Show Answer
**b) VSAM KSDS provides efficient key-based direct access without SQL overhead, which is optimal for CICS single-record lookups.** In a CICS environment, VSAM keyed access is extremely efficient for the most common operation: reading a single record by its primary key. A VSAM READ by key translates to a single index lookup followed by a direct data read, with no SQL parsing, optimization, or cursor management overhead. DB2 is better suited for complex queries involving joins, aggregations, and ad-hoc reporting, which is why the capstone maintains account data in DB2 as well for batch reporting purposes.Question 2
The capstone uses COMP-3 (packed decimal) for all financial amount fields. What is the primary reason for this choice over COMP (binary) or DISPLAY numeric?
- a) COMP-3 uses less storage than any other numeric format
- b) COMP-3 avoids binary-to-decimal conversion errors that can cause rounding discrepancies in financial calculations
- c) COMP-3 is the only format that supports signed values
- d) COMP-3 is required by the COBOL standard for fields used in COMPUTE statements
Show Answer
**b) COMP-3 avoids binary-to-decimal conversion errors that can cause rounding discrepancies in financial calculations.** Binary (COMP) fields cannot exactly represent many decimal fractions. For example, 0.10 in binary is a repeating fraction, which means a COMPUTE statement using binary fields can introduce tiny rounding errors that accumulate across millions of transactions. Packed decimal (COMP-3) stores each digit as a four-bit nibble, so decimal values are represented exactly. For financial applications where every cent must be accounted for, COMP-3 is the standard choice. DISPLAY numeric also represents decimals exactly but is less storage-efficient and slower for arithmetic.Question 3
Examine the following JCL step from the capstone's end-of-day job stream:
//STEP03 EXEC PGM=CAPTRANS,COND=(4,LT)
//STEPLIB DD DSN=BANK.PROD.LOADLIB,DISP=SHR
//TXNFILE DD DSN=BANK.DAILY.TXN.SORTED,DISP=SHR
//ACCTFILE DD DSN=BANK.VSAM.ACCOUNTS,DISP=SHR
//ERRFILE DD DSN=BANK.DAILY.TXN.ERRORS,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(5,2))
What does the COND=(4,LT) parameter mean?
- a) Skip this step if any prior step returned a code less than 4
- b) Execute this step only if the return code is less than 4
- c) Skip this step if any prior step returned a code greater than or equal to 4
- d) Execute this step only if 4 is less than all prior return codes
Show Answer
**a) Skip this step if any prior step returned a code less than 4.** The COND parameter syntax is COND=(code,operator), which reads as: "skip this step if code operator return-code is true." So COND=(4,LT) means "skip if 4 is less than the prior return code" -- that is, skip if the prior return code is 5 or higher. The practical effect is that STEP03 runs only if all prior steps completed with return code 4 or less (success or warning). This is a common pattern: allow warnings (RC=4) to propagate but stop the job stream if any step returns an error (RC=8 or higher).Question 4
In the capstone's CICS deposit transaction, what is the purpose of pseudo-conversational programming?
- a) To allow the program to process multiple transactions simultaneously
- b) To release the CICS task between user interactions, freeing system resources while the user reads the screen
- c) To encrypt the communication between the terminal and the CICS region
- d) To enable the program to call DB2 and VSAM in the same transaction
Show Answer
**b) To release the CICS task between user interactions, freeing system resources while the user reads the screen.** In a pseudo-conversational program, the CICS task issues SEND MAP to display a screen and then issues RETURN TRANSID specifying itself, storing necessary state in the COMMAREA. The task then ends. When the user presses Enter, CICS starts a new task for the same transaction, passing back the COMMAREA. This means the task exists only during the brief moment of actual processing, not during the seconds or minutes while the user reads the screen and types data. With thousands of concurrent users, this pattern reduces memory consumption and task control block usage by orders of magnitude compared to conversational programming.Question 5
The capstone's account record includes both ACCT-CURRENT-BALANCE and ACCT-AVAILABLE-BALANCE. What is the difference between these two fields?
- a) Current balance is in the local currency; available balance is in USD
- b) Current balance reflects all posted transactions; available balance subtracts holds, pending debits, and adds pending credits
- c) Current balance is calculated nightly in batch; available balance is updated in real-time by CICS
- d) They are redundant fields maintained for backward compatibility
Show Answer
**b) Current balance reflects all posted transactions; available balance subtracts holds, pending debits, and adds pending credits.** The available balance represents the funds the customer can actually use right now. The formula is: ACCT-AVAILABLE-BALANCE = ACCT-CURRENT-BALANCE - ACCT-HOLD-AMOUNT - ACCT-PENDING-DEBITS + ACCT-PENDING-CREDITS. For example, if a customer has a current balance of $5,000 but deposited a $2,000 check that is on a 2-day hold, the current balance is $5,000 but the available balance might be $3,000 (if the hold prevents access to the deposited funds). ATM withdrawal decisions use the available balance, not the current balance.Question 6
The CAPSTONE-CONSTANTS.CPY defines LIMIT-CTR-THRESHOLD as $10,000.00. What is this threshold used for?
- a) The maximum amount for a single ATM withdrawal
- b) The minimum balance required to open a Certificate of Deposit
- c) The Currency Transaction Report (CTR) filing threshold required by the Bank Secrecy Act
- d) The maximum amount that can be transferred between accounts in a single day
Show Answer
**c) The Currency Transaction Report (CTR) filing threshold required by the Bank Secrecy Act.** The Bank Secrecy Act requires financial institutions to file a Currency Transaction Report (CTR) with FinCEN for any cash transaction (or series of related cash transactions) of $10,000 or more. This is an anti-money-laundering requirement. The capstone uses this threshold in its CTR detection logic to flag qualifying transactions for regulatory reporting. Note that this is separate from the ATM daily limit (LIMIT-DAILY-ATM = $500.00) and the maximum single withdrawal (LIMIT-MAX-WITHDRAWAL = $10,000.00).Question 7
In the capstone's transaction record copybook, TXN-CHANNEL has values including 'BR' (branch), 'AT' (ATM), 'OL' (online), 'MB' (mobile), 'AC' (ACH), 'WR' (wire), and 'BA' (batch). Why is the channel field important for the application?
- a) Different channels have different fee structures and daily limits
- b) The channel determines which CICS transaction to route the request to
- c) Only branch and ATM transactions are valid; other channels are for future use
- d) The channel field is used only for statistical reporting and has no business logic impact
Show Answer
**a) Different channels have different fee structures and daily limits.** The channel code drives multiple business rules. ATM transactions have a daily withdrawal limit (LIMIT-DAILY-ATM = $500). Wire transfers (channel 'WR') incur fees that differ for domestic vs. international. Branch transactions ('BR') may be subject to CTR reporting if they involve cash. ACH transactions ('AC') may have multi-day settlement holds. The channel also determines which authentication was performed (ATM requires PIN, online requires multi-factor, branch requires teller verification), which affects fraud detection and regulatory compliance.Question 8
The capstone's batch interest calculation program uses the formula: daily_interest = balance * annual_rate / 365. What is the problem with this formula for leap years, and how should it be corrected?
- a) There is no problem; banks always use 365 days regardless of leap year
- b) The divisor should be 366 during leap years to avoid overpaying interest
- c) The formula should use 360 days per the banking convention for all years
- d) The answer depends on the day-count convention specified in the account agreement: 365/365, actual/365, actual/360, or 30/360
Show Answer
**d) The answer depends on the day-count convention specified in the account agreement: 365/365, actual/365, actual/360, or 30/360.** Different financial products use different day-count conventions. Common conventions include: Actual/365 (actual days elapsed divided by 365, used for many consumer products), Actual/360 (actual days divided by 360, common for commercial loans -- results in slightly higher effective interest), 30/360 (assumes 30 days per month and 360 days per year, common for bonds), and Actual/Actual (actual days divided by 365 or 366 depending on leap year). The capstone's simple 365-day divisor implements the Actual/365 convention. A production system would store the day-count convention as a product attribute and apply the correct formula accordingly.Question 9
Which of the following correctly describes the role of the CAPSTONE-CONSTANTS.CPY copybook's WS-COMM-AREA in the capstone application?
- a) It is the CICS COMMAREA used to pass data between pseudo-conversational interactions
- b) It is a general-purpose communication area used by the CALL interface between batch subprograms
- c) It serves both as a CICS COMMAREA for online programs and as a parameter block for batch CALL statements, providing a uniform interface across the application
- d) It is used exclusively by the error handling routine to pass error information back to the main program
Show Answer
**c) It serves both as a CICS COMMAREA for online programs and as a parameter block for batch CALL statements, providing a uniform interface across the application.** The WS-COMM-AREA structure contains function codes, account identifiers, amounts, error messages, and return codes. In the CICS environment, it is passed as the COMMAREA on EXEC CICS RETURN and EXEC CICS XCTL commands, preserving state between pseudo-conversational interactions and linking between programs. In the batch environment, the same structure is used as the parameter block when one program CALLs another. This design ensures that any business logic module can be invoked from either the online or batch context without modification, which is a key architectural principle of the capstone.Question 10
A CICS user attempts to withdraw $8,000 from a checking account with a current balance of $3,000, an overdraft limit of $2,000, and a linked savings account with $4,500. Assuming overdraft protection is enabled, what should the system do?
- a) Reject the withdrawal entirely because $8,000 exceeds the current balance plus overdraft limit
- b) Transfer $5,000 from savings and allow the withdrawal, charging an overdraft fee
- c) Transfer $4,500 from savings, then draw $500 from the overdraft limit, and allow the withdrawal with an overdraft fee
- d) Transfer $4,500 from savings, then draw $500 from the overdraft limit, and allow the withdrawal without an overdraft fee since the linked account covered most of it
Show Answer
**c) Transfer $4,500 from savings, then draw $500 from the overdraft limit, and allow the withdrawal with an overdraft fee.** The processing order is: (1) Calculate shortfall: $8,000 - $3,000 = $5,000 needed. (2) Check linked savings: $4,500 available, which is less than $5,000, so transfer all $4,500. (3) Remaining shortfall: $5,000 - $4,500 = $500. (4) Check overdraft limit: $2,000 available, which covers $500. (5) Allow the withdrawal, charging the overdraft fee (FEE-OVERDRAFT = $35.00) because the overdraft facility was used. The final checking balance is -$500 (within the $2,000 limit), the savings balance is $0, and a $35 fee is posted as a separate transaction. The key point is that the overdraft fee applies whenever the overdraft facility is used, even partially.Question 11
What is the purpose of maintaining both DB2 and VSAM copies of account data in the capstone architecture?
- a) DB2 is the system of record; VSAM is a read-only cache for faster CICS access
- b) VSAM is the system of record for balances; DB2 provides SQL query capability for reporting
- c) They serve different access patterns: VSAM for high-speed keyed lookups in CICS, DB2 for complex queries and joins in batch reporting
- d) The dual storage is a mistake in the capstone design that should be corrected
Show Answer
**c) They serve different access patterns: VSAM for high-speed keyed lookups in CICS, DB2 for complex queries and joins in batch reporting.** This is a common and intentional pattern in real banking systems. CICS transactions performing deposits, withdrawals, and balance inquiries need sub-second single-record access, which VSAM KSDS excels at. Batch reporting programs that calculate bank-wide totals, produce regulatory reports, or join account data with transaction history need SQL capabilities, which DB2 provides. The synchronization between the two stores is managed by the batch cycle: online transactions update VSAM immediately and queue DB2 updates, and the nightly batch ensures both stores are consistent before the next business day.Question 12
In the capstone's transaction processing flow, what is the correct order of operations for posting a deposit?
- a) Update balance -> Validate account -> Write history -> Post GL entry
- b) Validate account -> Update balance -> Write history -> Post GL entry
- c) Validate account -> Write history -> Update balance -> Post GL entry
- d) Post GL entry -> Validate account -> Update balance -> Write history
Show Answer
**b) Validate account -> Update balance -> Write history -> Post GL entry.** The correct sequence is: (1) Validate that the account exists, is active, and the deposit amount is valid. (2) Update the account balance fields (current balance, available balance, MTD deposits, YTD deposits, last transaction date). (3) Write the transaction history record with the balance-before and balance-after values. (4) Post the general ledger journal entry (debit cash, credit customer deposits). The history record must be written after the balance update because it needs the balance-after value. The GL entry comes last because it is a derived record that depends on the successful posting of the transaction.True/False Questions
Question 13
True or False: In the capstone application, the daily batch cycle must complete before CICS online transactions can resume the next morning.
Show Answer
**True.** The overnight batch cycle updates account balances with interest postings, fee charges, and statement generation. If CICS transactions were allowed to process while the batch was running, they could update balances that the batch is simultaneously modifying, causing data corruption. Banks typically close the online system (or restrict it to inquiry-only) during the batch window, then reopen it after the batch completes successfully. This "batch window" is a fundamental operational constraint of the traditional mainframe banking architecture.Question 14
True or False: The capstone's VSAM account file uses a non-unique alternate index on ACCT-CUST-NUMBER to allow retrieval of all accounts belonging to a single customer.
Show Answer
**True.** The CAPSTONE-ACCOUNT.CPY header comment specifies "Alternate Key: ACCT-CUST-NUMBER (positions 11-20, non-unique)." This allows the application to browse all accounts for a given customer by reading through the alternate index path. The alternate index is non-unique because a single customer can have multiple accounts (checking, savings, CD, loan, etc.).Question 15
True or False: In the capstone's general ledger design, every financial transaction must produce at least two journal entries to maintain double-entry bookkeeping.
Show Answer
**True.** Double-entry bookkeeping requires that every transaction be recorded as at least one debit and at least one credit, and the total debits must equal the total credits. For example, a customer deposit debits the bank's cash account and credits the customer deposit liability account. A transfer between two customer accounts debits one customer's account and credits the other's. The trial balance report verifies that total debits equal total credits across all general ledger accounts.Question 16
True or False: The capstone's CICS programs should use conversational programming (holding the task active while the user reads the screen) for financial transactions to ensure data consistency.
Show Answer
**False.** Conversational programming would hold CICS task resources (task control blocks, storage, DB2 threads) for the entire duration of the user's think time, which could be seconds or minutes. With hundreds or thousands of concurrent users, this would exhaust CICS resources. The capstone uses pseudo-conversational programming, which ends the task between screen interactions. Data consistency is maintained through the COMMAREA (which preserves state) and by re-reading and re-validating data at the start of each interaction to detect concurrent changes.Question 17
True or False: The ACCT-FLAG-ESCHEAT field in the account record relates to tax reporting requirements similar to 1099-INT.
Show Answer
**False.** Escheatment is the legal process by which unclaimed or abandoned property (including dormant bank accounts) is turned over to the state government. The ACCT-FLAG-ESCHEAT flag indicates that the account has been identified as a candidate for escheatment due to prolonged inactivity with no customer contact. This is separate from 1099-INT tax reporting, which is controlled by the ACCT-FLAG-1099 field. Escheatment is governed by state Uniform Unclaimed Property Acts, not the IRS.Question 18
True or False: In the capstone application, the SORT utility used in the batch JCL job stream is a component of COBOL.
Show Answer
**False.** The SORT utility (DFSORT on IBM z/OS, or SyncSort) is a separate system product, not part of COBOL. COBOL has its own SORT verb for internal sorting, but the JCL job stream typically invokes the external sort utility (PGM=SORT or PGM=ICEMAN) for sorting large files because the external utility is highly optimized for I/O performance and can sort files much faster than an internal COBOL SORT. The COBOL SORT verb itself uses the external sort utility under the covers on z/OS.Question 19
True or False: The WS-DAYS-TABLE in CAPSTONE-CONSTANTS.CPY always correctly handles the number of days in February.
Show Answer
**False.** The table defines February as having 28 days (FILLER PIC 9(2) VALUE 28). This is correct for non-leap years but incorrect for leap years, where February has 29 days. The program that uses this table must include separate leap year logic to check if the year is divisible by 4 (and not by 100, unless also by 400) and adjust the February value accordingly before using the table for date calculations.Question 20
True or False: The capstone's COMM-AMOUNT field uses PIC S9(11)V99 COMP-3, meaning it can store amounts up to $99,999,999,999.99.
Show Answer
**True.** The PIC S9(11)V99 definition means 11 integer digits and 2 decimal digits, with a sign. The maximum positive value is 99999999999.99, which is approximately $100 billion. This is more than adequate for individual transaction amounts in a retail banking application but would be appropriate for aggregated amounts in a large bank's general ledger totals. The sign (S) allows for negative values, which are needed for debits, reversals, and overdraft balances.Code Analysis Questions
Question 21
Examine the following paragraph from the capstone's transaction posting program. What is the bug, and what financial impact could it have?
3000-POST-TRANSACTION.
READ ACCT-FILE INTO ACCOUNT-RECORD
INVALID KEY
MOVE 'R' TO TXN-STATUS
PERFORM 3500-WRITE-REJECT
END-READ
IF TXN-IS-DEPOSIT
ADD TXN-AMOUNT TO ACCT-CURRENT-BALANCE
ADD TXN-AMOUNT TO ACCT-AVAILABLE-BALANCE
ADD TXN-AMOUNT TO ACCT-MTD-DEPOSITS
ADD TXN-AMOUNT TO ACCT-YTD-DEPOSITS
ADD 1 TO ACCT-MTD-TXN-COUNT
MOVE WS-PROCESS-DATE TO ACCT-LAST-TXN-DATE
REWRITE ACCOUNT-RECORD
END-IF
.
Show Answer
**Bug: Missing NOT INVALID KEY or scope termination after the INVALID KEY handling.** When the READ fails (INVALID KEY), the program sets TXN-STATUS to 'R' and writes a reject record, but it does not stop processing. Execution falls through to the IF TXN-IS-DEPOSIT block, which operates on whatever data was left in ACCOUNT-RECORD from a previous iteration. If TXN-IS-DEPOSIT is true, the program will add the deposit amount to the wrong account's balance and REWRITE an incorrect record. The fix requires either adding a NOT INVALID KEY clause to guard the processing logic, or using a status flag and checking it before proceeding: 3000-POST-TRANSACTION.
READ ACCT-FILE INTO ACCOUNT-RECORD
INVALID KEY
MOVE 'R' TO TXN-STATUS
PERFORM 3500-WRITE-REJECT
NOT INVALID KEY
PERFORM 3100-APPLY-TRANSACTION
END-READ
.
The financial impact could be severe: depositing money into the wrong account means one customer gains funds they should not have, and the intended recipient does not receive their deposit.
Question 22
Review the following interest calculation code. Identify all issues.
4000-CALCULATE-INTEREST.
COMPUTE WS-DAILY-INTEREST =
ACCT-CURRENT-BALANCE *
ACCT-INTEREST-RATE / 365
ADD WS-DAILY-INTEREST
TO ACCT-ACCRUED-INTEREST
ADD WS-DAILY-INTEREST
TO ACCT-MTD-INTEREST
ADD WS-DAILY-INTEREST
TO ACCT-YTD-INTEREST
.
Show Answer
**Multiple issues:** 1. **Missing ROUNDED clause.** The COMPUTE should use ROUNDED to ensure the result is rounded to the nearest cent: `COMPUTE WS-DAILY-INTEREST ROUNDED = ...`. Without ROUNDED, COBOL truncates the result, which over millions of accounts and days systematically underpays interest. 2. **No check for negative balance.** If ACCT-CURRENT-BALANCE is negative (overdraft), the calculation produces negative interest, which would reduce ACCT-ACCRUED-INTEREST. Most banks do not pay interest on negative balances; they charge overdraft fees instead. The code should check `IF ACCT-CURRENT-BALANCE > ZERO` before calculating. 3. **No check for account status.** The code calculates interest for all accounts regardless of status. Closed, frozen, or dormant accounts should not accrue interest. The code should check `IF ACCT-IS-ACTIVE` before processing. 4. **No check for account type.** Loan accounts (ACCT-IS-LOAN) accrue interest differently from deposit accounts. The same formula should not be applied to both. 5. **Hardcoded 365-day divisor.** As discussed in Question 8, the day-count convention should be product-specific, not hardcoded. 6. **No DB2 update.** If the capstone maintains DB2 in sync with VSAM, the accrued interest should be updated in both stores.Question 23
The following code attempts to build a JSON response for an account inquiry API. What problems does it have?
5000-BUILD-JSON-RESPONSE.
MOVE ACCT-NUMBER TO JS-ACCT-NUM
MOVE ACCT-TYPE TO JS-ACCT-TYPE
MOVE ACCT-CURRENT-BALANCE TO JS-BALANCE
MOVE CUST-SSN TO JS-CUST-SSN
MOVE CUST-FIRST-NAME TO JS-CUST-FNAME
MOVE CUST-LAST-NAME TO JS-CUST-LNAME
JSON GENERATE WS-JSON-OUTPUT
FROM JS-RESPONSE-RECORD
COUNT IN WS-JSON-LENGTH
END-JSON
EXEC CICS WEB SEND
FROM(WS-JSON-OUTPUT)
FROMLENGTH(WS-JSON-LENGTH)
MEDIATYPE('application/json')
STATUSCODE(200)
END-EXEC
.
Show Answer
**Multiple problems:** 1. **Sensitive data exposure.** The code includes CUST-SSN (Social Security Number) in the JSON response. An API should never expose SSNs in a response payload. This is a serious security and compliance violation (PCI-DSS, GLBA, state privacy laws). 2. **No error handling on JSON GENERATE.** The JSON GENERATE statement can fail if the output field is too small or if the source data contains invalid characters. The code should check the return code and handle the ON EXCEPTION condition. 3. **No error handling on EXEC CICS WEB SEND.** The CICS command can fail, and without RESP and RESP2 handling, the program will abend. 4. **STATUSCODE is a response code, not a literal in that context.** Depending on the CICS version, the syntax may require STATUSCODE to be a data name, not a literal. 5. **No Content-Length header.** While some CICS versions handle this automatically with FROMLENGTH, best practice is to ensure the content length is correctly communicated. 6. **COBOL trailing spaces.** COBOL string fields are padded with spaces. JS-CUST-FNAME and JS-CUST-LNAME will include trailing spaces in the JSON output (e.g., `"firstName": "John "`). The fields should be trimmed using FUNCTION TRIM or a NAME SUPPRESS clause on JSON GENERATE. Corrected approach: JSON GENERATE WS-JSON-OUTPUT
FROM JS-RESPONSE-RECORD
COUNT IN WS-JSON-LENGTH
NAME OF JS-CUST-SSN IS OMITTED
SUPPRESS JS-CUST-SSN
ON EXCEPTION
PERFORM 9100-JSON-ERROR
END-JSON
Question 24
Analyze this JCL for the capstone's end-of-day job. What is the vulnerability?
//BANKDAY JOB (ACCT),'EOD PROCESSING',
// CLASS=A,MSGCLASS=X,NOTIFY=&SYSUID
//*
//STEP01 EXEC PGM=CAPVALID
//TXNIN DD DSN=BANK.DAILY.TRANSACTIONS,DISP=SHR
//TXNOUT DD DSN=BANK.DAILY.TXN.VALID,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(100,20))
//*
//STEP02 EXEC PGM=SORT
//SORTIN DD DSN=BANK.DAILY.TXN.VALID,DISP=SHR
//SORTOUT DD DSN=BANK.DAILY.TXN.SORTED,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(100,20))
//SYSIN DD *
SORT FIELDS=(1,10,CH,A,23,10,CH,A)
/*
//*
//STEP03 EXEC PGM=CAPTRANS
//TXNFILE DD DSN=BANK.DAILY.TXN.SORTED,DISP=SHR
//ACCTFILE DD DSN=BANK.VSAM.ACCOUNTS,DISP=SHR
//*
//STEP04 EXEC PGM=CAPINTRN
//ACCTFILE DD DSN=BANK.VSAM.ACCOUNTS,DISP=SHR
Show Answer
**Critical vulnerability: No COND parameters or IF/THEN/ELSE constructs to check return codes between steps.** If STEP01 (validation) fails with a return code of 8 or 16, STEP02 (sort) will still execute, potentially sorting an incomplete or corrupted file. If STEP02 fails, STEP03 (transaction posting) will attempt to process a non-existent or empty sorted file, likely ABENDing or posting zero transactions. If STEP03 fails, STEP04 (interest calculation) will run on accounts that may not have their correct balances. **Additional issues:** 1. **No backup step.** The VSAM account file should be backed up before STEP03 modifies it. If the job fails midway through posting, there is no way to restore the file to its pre-processing state. 2. **No SORTWK DD statements.** STEP02's SORT may fail with large volumes because no sort work files are defined. DFSORT needs temporary work space. 3. **DISP=SHR on ACCTFILE in STEP03.** A program that REWRITEs VSAM records should open the file with DISP=OLD to ensure exclusive access. DISP=SHR allows concurrent access, which could cause corruption if another job updates the file simultaneously. 4. **No error file DD in STEP03.** The transaction posting program presumably writes rejected transactions somewhere, but no error output DD is defined. The corrected job should include `COND=(4,LT)` on each step after STEP01, a backup step before STEP03, SORTWK DD statements in STEP02, and DISP=OLD on the VSAM file in STEP03.Question 25
The following CICS code handles a transfer between two accounts. What concurrency issue exists?
6000-PROCESS-TRANSFER.
* Read source account
MOVE COMM-ACCT-NUMBER TO ACCT-NUMBER
EXEC CICS READ
DATASET('ACCTFILE')
INTO(SOURCE-ACCOUNT)
RIDFLD(ACCT-NUMBER)
LENGTH(ACCT-REC-LENGTH)
RESP(WS-RESP)
END-EXEC
* Read target account
MOVE COMM-TARGET-ACCT TO ACCT-NUMBER
EXEC CICS READ
DATASET('ACCTFILE')
INTO(TARGET-ACCOUNT)
RIDFLD(ACCT-NUMBER)
LENGTH(ACCT-REC-LENGTH)
RESP(WS-RESP)
END-EXEC
* Verify sufficient funds
IF SOURCE-ACCT-BALANCE >= COMM-AMOUNT
* Debit source
SUBTRACT COMM-AMOUNT
FROM SOURCE-ACCT-BALANCE
EXEC CICS REWRITE
DATASET('ACCTFILE')
FROM(SOURCE-ACCOUNT)
LENGTH(ACCT-REC-LENGTH)
RESP(WS-RESP)
END-EXEC
* Credit target
ADD COMM-AMOUNT TO TARGET-ACCT-BALANCE
EXEC CICS REWRITE
DATASET('ACCTFILE')
FROM(TARGET-ACCOUNT)
LENGTH(ACCT-REC-LENGTH)
RESP(WS-RESP)
END-EXEC
END-IF
.
Show Answer
**Critical concurrency issue: The READ commands do not request UPDATE mode, and there is a time-of-check-to-time-of-use (TOCTOU) gap.** **Problem 1: No record-level locking.** The EXEC CICS READ statements do not specify the UPDATE option. Without UPDATE, CICS does not acquire a lock on the record. This means another task could modify the same account between the READ and the REWRITE. In fact, the REWRITE will fail because CICS requires that the record being rewritten was obtained by a READ UPDATE. **Problem 2: TOCTOU race condition.** Even with READ UPDATE, a race condition exists: between reading the source account and rewriting it, another transaction could have modified the balance. The balance check `IF SOURCE-ACCT-BALANCE >= COMM-AMOUNT` may pass based on stale data. **Problem 3: Non-atomic transfer.** If the program ABENDs after debiting the source but before crediting the target, money disappears. The two updates are not within an atomic unit of work. **Fix:** * Read source WITH UPDATE (acquires lock)
EXEC CICS READ UPDATE
DATASET('ACCTFILE')
INTO(SOURCE-ACCOUNT)
RIDFLD(SOURCE-ACCT-KEY)
LENGTH(ACCT-REC-LENGTH)
RESP(WS-RESP)
END-EXEC
* Read target WITH UPDATE (acquires lock)
EXEC CICS READ UPDATE
DATASET('ACCTFILE')
INTO(TARGET-ACCOUNT)
RIDFLD(TARGET-ACCT-KEY)
LENGTH(ACCT-REC-LENGTH)
RESP(WS-RESP)
END-EXEC
Additionally, the program should use EXEC CICS SYNCPOINT to commit both updates atomically, or use EXEC CICS SYNCPOINT ROLLBACK if either update fails. For deadlock prevention, always acquire locks in a consistent order (e.g., lower account number first).
Question 26
Review this batch report program snippet. What output formatting issues exist?
7100-PRINT-ACCOUNT-LINE.
MOVE ACCT-NUMBER TO RPT-ACCT-NUM
MOVE ACCT-CURRENT-BALANCE TO RPT-BALANCE
MOVE ACCT-INTEREST-RATE TO RPT-RATE
MOVE ACCT-OPEN-DATE TO RPT-OPEN-DT
WRITE RPT-RECORD FROM WS-DETAIL-LINE
AFTER ADVANCING 1 LINE
ADD 1 TO WS-LINE-COUNT
IF WS-LINE-COUNT > 55
PERFORM 7200-PAGE-BREAK
END-IF
.
Show Answer
**Multiple formatting issues:** 1. **Page overflow check is after the WRITE.** The line count check should happen BEFORE writing the detail line. As written, the program writes a line, then checks if the page is full. This means the 56th line will print past the bottom of the page before the page break occurs. The check should precede the WRITE. 2. **No initialization of the detail line.** The WS-DETAIL-LINE is not initialized (INITIALIZE or MOVE SPACES) before populating fields. This means fields from a previous iteration could bleed through if the current record has shorter data. 3. **ACCT-INTEREST-RATE formatting.** The rate field is PIC 9V9(6) in the copybook (e.g., 0.025000 for 2.5%). If RPT-RATE is a display field like PIC Z.9(4), the value will show as "0.0250" rather than "2.50%". The rate should be multiplied by 100 before display and formatted with a percent sign. 4. **No page number tracking.** The page break paragraph is called but there is no evidence of incrementing a page counter or printing it in the header. Corrected: 7100-PRINT-ACCOUNT-LINE.
IF WS-LINE-COUNT >= 55
PERFORM 7200-PAGE-BREAK
END-IF
INITIALIZE WS-DETAIL-LINE
MOVE ACCT-NUMBER TO RPT-ACCT-NUM
MOVE ACCT-CURRENT-BALANCE TO RPT-BALANCE
COMPUTE WS-DISPLAY-RATE =
ACCT-INTEREST-RATE * 100
MOVE WS-DISPLAY-RATE TO RPT-RATE
MOVE ACCT-OPEN-DATE TO RPT-OPEN-DT
WRITE RPT-RECORD FROM WS-DETAIL-LINE
AFTER ADVANCING 1 LINE
ADD 1 TO WS-LINE-COUNT
.
Question 27
The following code from the capstone's CICS inquiry program retrieves customer accounts using a DB2 cursor. What performance issues exist?
4000-DISPLAY-ACCOUNTS.
MOVE COMM-CUST-NUMBER TO HV-CUST-NUMBER
EXEC SQL
DECLARE ACCT-CSR CURSOR FOR
SELECT ACCT_NUMBER, ACCT_TYPE,
CURRENT_BALANCE, ACCT_STATUS
FROM ACCOUNT
WHERE CUST_ID = :HV-CUST-NUMBER
ORDER BY ACCT_NUMBER
END-EXEC
EXEC SQL OPEN ACCT-CSR END-EXEC
PERFORM UNTIL SQLCODE NOT = 0
EXEC SQL
FETCH ACCT-CSR
INTO :HV-ACCT-NUM, :HV-ACCT-TYPE,
:HV-BALANCE, :HV-STATUS
END-EXEC
IF SQLCODE = 0
ADD 1 TO WS-ACCT-IDX
PERFORM 4100-FORMAT-ACCT-LINE
END-IF
END-PERFORM
EXEC SQL CLOSE ACCT-CSR END-EXEC
.
Show Answer
**Performance issues:** 1. **Missing FOR FETCH ONLY clause.** The cursor does not specify FOR FETCH ONLY (or FOR READ ONLY). Without this, DB2 may acquire update locks on the rows, blocking other transactions. Since this is an inquiry screen, no updates will be made, so the cursor should declare its intent as read-only. 2. **Missing OPTIMIZE FOR clause.** In a CICS transaction, the cursor typically retrieves a small number of rows (a customer rarely has more than 10 accounts). Adding `OPTIMIZE FOR 10 ROWS` tells DB2 to use a smaller buffer and avoid the overhead of optimizing for a large result set. 3. **No LIMIT on rows fetched.** If a data error caused a customer to have thousands of spurious account links, this loop would fetch them all, potentially causing the CICS transaction to exceed its time limit. A safeguard like `FETCH FIRST 20 ROWS ONLY` or a counter-based exit would prevent runaway queries. 4. **Cursor DECLARE placement.** While this code works, best practice on z/OS is to place DECLARE CURSOR in WORKING-STORAGE SECTION (as a static SQL declaration), not inline in the PROCEDURE DIVISION. The actual declaration is processed at precompile time regardless of placement, but coding it in WORKING-STORAGE makes the code clearer. Improved cursor: EXEC SQL
DECLARE ACCT-CSR CURSOR FOR
SELECT ACCT_NUMBER, ACCT_TYPE,
CURRENT_BALANCE, ACCT_STATUS
FROM ACCOUNT
WHERE CUST_ID = :HV-CUST-NUMBER
ORDER BY ACCT_NUMBER
FETCH FIRST 20 ROWS ONLY
FOR FETCH ONLY
OPTIMIZE FOR 10 ROWS
END-EXEC