# CICS Transaction Processing

> [← Back to README](../../README.md) | [VSAM Operations →](./vsam-operations.md)

## Pseudo-Conversational Programming Model

All CardDemo online programs use the CICS pseudo-conversational model where programs do not remain resident between user interactions. State is preserved via COMMAREA (COCOM01Y.cpy).

**Pattern:**
1. Program starts → Check EIBCALEN (if 0, first time; if >0, returning)
2. Receive BMS map input → Process user action based on EIBAID
3. Perform business logic → Access VSAM files
4. Send updated BMS map → EXEC CICS RETURN TRANSID(...) COMMAREA(...)

## COMMAREA Usage (COCOM01Y.cpy)

The `CARDDEMO-COMMAREA` structure carries:
- General info: current/previous program names, transaction IDs
- User session data: user ID, user type (admin/regular)
- Navigation state: selected options, page positions
- Cross-program data: account number, card number being processed

All 20+ online programs include `COPY COCOM01Y` to share this common area.

## BMS Map Processing

Each screen uses a BMS mapset with matching COBOL copybook:
- **BMS source** (`.bms` file) → Assembled into physical/symbolic maps
- **Symbolic map** (`.CPY` in cpy-bms/) → COBOL data structure for field access
- **SEND MAP** → Display data to terminal
- **RECEIVE MAP** → Get user input

**Attribute control:** DFHBMSCA copybook provides field attribute bytes. CSSETATY copybook (with COPY REPLACING) sets colors based on validation flags.

## File Control Operations

| Operation | CICS Command | Usage |
|:----------|:-------------|:------|
| Direct Read | `EXEC CICS READ FILE(...) INTO(...) RIDFLD(...)` | Single record by key |
| Read for Update | `EXEC CICS READ FILE(...) INTO(...) RIDFLD(...) UPDATE` | Lock for update |
| Update | `EXEC CICS REWRITE FILE(...) FROM(...)` | After READ UPDATE |
| Write | `EXEC CICS WRITE FILE(...) FROM(...) RIDFLD(...)` | New record |
| Delete | `EXEC CICS DELETE FILE(...) RIDFLD(...)` | Remove record |
| Browse Start | `EXEC CICS STARTBR FILE(...) RIDFLD(...)` | Begin sequential read |
| Browse Next | `EXEC CICS READNEXT FILE(...) INTO(...) RIDFLD(...)` | Next in sequence |
| Browse End | `EXEC CICS ENDBR FILE(...)` | End browse |

## TD Queue (Transient Data)

CORPT00C uses TD queue for batch job submission:
```cobol
EXEC CICS WRITEQ TD QUEUE('JOBS') FROM(jcl-record) LENGTH(80)
```
CSD defines JOBS as extrapartition TD queue → DD=INREADER for JCL submission.

---

*See also: [Patterns](../../architecture/patterns.md) | [Interfaces](../../reference/interfaces.md)*
