This document summarizes critical business rules that are implemented in the CardDemo codebase. As a developer, you must understand and enforce these rules when modifying existing code or adding new features.
Business Rule: Account balance cannot exceed the credit limit.
Implementation: CBTRN02C.cbl lines 407-413
IF WS-ACCT-CURR-BAL > WS-ACCT-CREDIT-LIMIT
SET REJECT-REASON TO 102
MOVE 'OVERLIMIT TRANSACTION' TO REJECT-REASON-DESC
PERFORM WRITE-REJECT-TRAN
Why it matters: Prevents accounts from going overlimit. If you modify transaction posting, ensure this check remains in place.
Business Rule: Transactions received after account expiration date must be rejected.
Implementation: CBTRN02C.cbl lines 414-420
Why it matters: Prevents charging expired accounts. Check expiration date before posting transactions.
Business Rule: When account current cycle debit equals zero, set it to 2525.00.
Implementation: CBACT01C.cbl lines 236-238
Why it matters: Ensures accounts have minimum activity for testing/demonstration purposes. This is a demo rule you might remove in production.
Business Rule: Card numbers must be exactly 16 numeric digits.
Implementation: COCRDLIC.cbl lines 1017-1025, COCRDUPC.cbl lines 784-794
Why it matters: Ensures card number format consistency. Always validate card number format before writes.
Business Rule: Card embossed name can only contain alphabetic characters and spaces (no numbers or special characters).
Implementation: COCRDUPC.cbl lines 822-837
IF CARDMI-NAME(I:1) NOT ALPHABETIC
AND CARDMI-NAME(I:1) NOT = SPACE
SET NAME-INVALID TO TRUE
Why it matters: Prevents invalid characters from being embossed on physical cards. Validate before card updates.
Business Rule: Card expiry month must be 1-12, year must be 1950-2099.
Implementation: COCRDUPC.cbl lines 883-943
Why it matters: Prevents invalid expiration dates that would cause transaction authorization failures.
Business Rule: Each card must be linked to exactly one account.
Implementation: Cross-reference file (CCXREF) maintains this relationship
Why it matters: Foundation of transaction processing. Never create orphan cards or break card-account links.
Business Rule: Transactions must be validated in this order: (1) card lookup, (2) account lookup, (3) business rules.
Implementation: CBTRN02C.cbl lines 370-378
PERFORM CHECK-XREF-RETURN
IF XREF-CARD-FOUND
PERFORM READ-ACCTDAT-RECORD
IF ACCTDAT-FOUND
PERFORM VALIDATE-BUSINESS-RULES
Why it matters: Ensures proper error messages. Don't check business rules if card/account doesn't exist.
Business Rule: If card number is not found in cross-reference file, reject with reason code 100.
Implementation: CBTRN02C.cbl lines 382-391
Why it matters: Prevents posting to non-existent cards. All transaction processing must validate card first.
Business Rule: If transaction amount ≥ 0, add to current cycle credit. Otherwise, add to current cycle debit.
Implementation: CBTRN02C.cbl lines 547-552
ADD WS-TRAN-AMT TO ACCOUNT-CURR-BAL
IF WS-TRAN-AMT >= ZERO
ADD WS-TRAN-AMT TO ACCOUNT-CURR-CYC-CREDIT
ELSE
ADD WS-TRAN-AMT TO ACCOUNT-CURR-CYC-DEBIT
Why it matters: Determines how transactions affect cycle totals. Credits and debits are tracked separately for statement generation.
Business Rule: When a transaction category balance record doesn't exist, create it. When it exists, update it.
Implementation: CBTRN02C.cbl lines 495-527
Why it matters: Enables spending analysis by category. Must handle both create and update cases.
Business Rule: Payment cannot be processed if account balance ≤ 0.
Implementation: COBIL00C.cbl lines 198-206
IF ACCOUNT-CURR-BAL <= 0
MOVE 'You have nothing to pay...' TO MESSAGEO
Why it matters: Prevents negative balance from payment. Check balance before allowing payment.
Business Rule: Bill payment amount equals the full current balance.
Implementation: COBIL00C.cbl line 224
COMPUTE WS-TRAN-AMT = ACCOUNT-CURR-BAL * -1
Why it matters: CardDemo only supports full balance payments. If you need partial payments, modify this logic.
Business Rule: Bill payments must use transaction type '02' and category 2.
Implementation: COBIL00C.cbl lines 220-222
Why it matters: Ensures payments are correctly categorized in reports and statements.
Business Rule: If authorization response code = '00', status is 'A' (Approved). Otherwise, status is 'D' (Declined).
Implementation: COPAUS0C.cbl lines 536-540
IF AUTH-RESP-CD = '00'
MOVE 'A' TO WS-APPROVAL-STATUS
ELSE
MOVE 'D' TO WS-APPROVAL-STATUS
Why it matters: Standard authorization response codes. Response code '00' is the only success code.
Business Rule: Account numbers must be exactly 11 numeric digits, cannot be blank, spaces, or zeros.
Implementation: COACTUPC.cbl lines 725-756
Why it matters: Primary key for account lookups. Always validate format before file operations.
Business Rule: First 3 digits of SSN cannot be 0, 666, or 900-999.
Implementation: COACTUPC.cbl lines 121-123
Why it matters: Follows real-world SSN validation rules. Important for customer data integrity.
Business Rule: Birth date year, month, and day must all be valid numeric values within acceptable ranges.
Implementation: COACTUPC.cbl lines 216-230
Why it matters: Prevents invalid dates that cause downstream processing errors.
Business Rule: Admin users see admin menu, regular users see main menu. No crossover allowed.
Implementation: COSGN00C.cbl sign-on logic, menu programs filter based on user type
Why it matters: Fundamental security control. Never show admin functions to regular users, even if disabled.
Business Rule: User type must be 'A' (admin) or 'U' (regular user).
Implementation: Throughout user management programs
Why it matters: Binary classification drives all authorization decisions. Don't add new user types without updating all authorization checks.
Business Rule: Display maximum 5 transactions per statement page for readability.
Implementation: CBSTM03A.cbl statement formatting logic
Why it matters: Affects statement pagination and formatting. Change carefully to avoid layout issues.
| Rule Category | Rule | Impact if Violated | Where Enforced |
|---|---|---|---|
| Credit Limit | Balance cannot exceed limit | Overlimit charges, compliance issues | CBTRN02C |
| Card Format | 16-digit numeric only | Authorization failures, invalid cards | COCRDLIC, COCRDUPC |
| Transaction Validation | Card must exist in XREF | Posting to wrong account, lost transactions | CBTRN02C |
| Payment Processing | Cannot pay zero balance | System errors, confused customers | COBIL00C |
| Authorization | Response '00' = approved only | Incorrect transaction approvals | COPAUS0C |
| Security | Role-based access enforced | Unauthorized data access, compliance violation | All online programs |
Search Patterns:
CREDIT-LIMIT, OVERLIMIT, CURR-BALCARD-NUM, XREF, INVALID CARDPOST, UPDATE-ACCOUNT, TRANSACTION-AMTAUTH-RESP, APPROVAL, DECLINECURR-BAL, CYCLE-CREDIT, CYCLE-DEBITKey Programs:
CBTRN02C.cblCOCRDUPC.cblCOACTUPC.cblCOBIL00C.cblCOPAUS0C.cbl