CBSTM03B
Source: cbl/CBSTM03B.CBL
Type: Batch program
CBSTM03B — File Access Subroutine
Purpose
CBSTM03B is a batch COBOL subroutine used by the CardDemo application's statement-generation process. It provides a single, generic entry point for opening, reading, and closing four VSAM-indexed master/transaction files (transactions, card cross-reference, customer, and account). Rather than performing its own business logic, it acts as a low-level I/O service that other programs (e.g., a statement-creation program) call to fetch records by key or in sequence.
How it works
Processing is driven entirely by parameters passed in via LINKAGE SECTION (LK-M03B-AREA), not by any internal control flow of its own:
- 0000-START — the single entry point (
PROCEDURE DIVISION USING LK-M03B-AREA). It inspectsLK-M03B-DD(the target file/DD name) and dispatches to one of four paragraph ranges viaEVALUATE: 'TRNXFILE'→1000-TRNXFILE-PROCthru1999-EXIT'XREFFILE'→2000-XREFFILE-PROCthru2999-EXIT'CUSTFILE'→3000-CUSTFILE-PROCthru3999-EXIT'ACCTFILE'→4000-ACCTFILE-PROCthru4999-EXIT-
Any other value falls through to 9999-GOBACK, ending the call with no action taken.
-
Each of the four
xxx0-...-PROCparagraphs follows the same pattern, keyed off the operation flagLK-M03B-OPER(via 88-levelsM03B-OPEN,M03B-READ,M03B-READ-K,M03B-CLOSE,M03B-WRITE,M03B-REWRITE): - OPEN ('O') — opens the file
INPUT. - READ ('R') — sequential read (only supported for
TRNXFILE/1000-TRNXFILE-PROCandXREFFILE/2000-XREFFILE-PROC, matching theirACCESS MODE IS SEQUENTIAL). - READ-K ('K') — keyed random read (only supported for
CUSTFILE/3000-CUSTFILE-PROCandACCTFILE/4000-ACCTFILE-PROC, matching theirACCESS MODE IS RANDOM); the key is built by movingLK-M03B-KEY(1:LK-M03B-KEY-LN)into the file's record key field before the read. - CLOSE ('C') — closes the file.
-
After the operation, control drops to the paragraph's
x900-EXIT, which moves the file's two-byteFILE STATUSfield intoLK-M03B-RCfor the caller to inspect, then falls intox999-EXIT(a bareEXIT) and returns to9999-GOBACK/GOBACK. -
The 88-levels
M03B-WRITEandM03B-REWRITEare defined but no paragraph implements them — passing those operation codes results in none of theIFconditions matching, so the paragraph does nothing except fall through to move the (unchanged) file status intoLK-M03B-RC.
Inputs & outputs
| File / DD | Access mode | Key | Purpose |
|---|---|---|---|
TRNX-FILE (DD TRNXFILE) |
Indexed, sequential, input only | FD-TRNXS-ID (card no. + transaction id) |
Transaction records read sequentially for statement processing. |
XREF-FILE (DD XREFFILE) |
Indexed, sequential, input only | FD-XREF-CARD-NUM |
Card-to-account cross-reference data, read sequentially. |
CUST-FILE (DD CUSTFILE) |
Indexed, random, input only | FD-CUST-ID (9-byte customer id) |
Customer master data, looked up by key on demand. |
ACCT-FILE (DD ACCTFILE) |
Indexed, random, input only | FD-ACCT-ID (11-digit account id) |
Account master data, looked up by key on demand. |
Linkage interface (LK-M03B-AREA) — this is the program's true "input/output" contract with its caller:
- LK-M03B-DD — which file to operate on (TRNXFILE, XREFFILE, CUSTFILE, ACCTFILE).
- LK-M03B-OPER — operation code (O=open, R=sequential read, K=keyed read, C=close; W/Z defined but unused).
- LK-M03B-KEY / LK-M03B-KEY-LN — key value and length, used only for keyed reads (CUST-FILE, ACCT-FILE).
- LK-M03B-FLDT — 1000-byte buffer the record is read into (READ ... INTO LK-M03B-FLDT).
- LK-M03B-RC — 2-byte return code, set from the file's FILE STATUS after each operation, for the caller to check success/failure.
No CICS commands, SQL tables, copybooks, or subordinate program calls are used — this is a purely batch, self-contained VSAM I/O module.
Things to know
- No explicit error handling. None of the
OPEN,READ, orCLOSEstatements haveINVALID KEY,AT END, orNOT ON SIZE ERROR/error clauses. The only feedback to the caller is the raw file-status code copied intoLK-M03B-RCafter the fact — callers must check this themselves; the subroutine itself never branches on failure. - Silent no-op for unsupported operations. Requesting
WRITE('W') orREWRITE('Z') — or aREADon the random-access files, orREAD-Kon the sequential files — matches none of theIFconditions in the relevant paragraph, so the routine does nothing but still returns a (stale/unchanged) status code. This could mask caller bugs. - Unknown DD name is silently ignored. If
LK-M03B-DDdoesn't match one of the four expected values,EVALUATE ... WHEN OTHERjumps straight to9999-GOBACK— no error is raised, and no status is returned inLK-M03B-RC. - All files opened
INPUTonly — this module is read-only despite the presence ofWRITE/REWRITEoperation flags in the linkage area, suggesting either dead/reserved code or functionality removed/not yet implemented. - Fixed record layouts. Buffer sizes are hard-coded per file (e.g.,
FD-ACCT-DATA PIC X(289),LK-M03B-FLDT PIC X(1000)) — any mismatch between actual record layouts (defined elsewhere, likely in copybooks used by the caller) and these sizes isn't validated here. - State is not reused across calls in a documented way — each call is a single discrete operation (open/read/close) driven by the linkage parameters; the caller is responsible for sequencing OPEN → (READ/READ-K)* → CLOSE correctly, since this subroutine enforces no state machine or call ordering itself.
Files
| Logical file | DD name |
|---|---|
| TRNX-FILE | TRNXFILE |
| XREF-FILE | XREFFILE |
| CUST-FILE | CUSTFILE |
| ACCT-FILE | ACCTFILE |
Paragraph flow
flowchart TD
0000_START["0000-START"]
9999_GOBACK["9999-GOBACK"]
1000_TRNXFILE_PROC["1000-TRNXFILE-PROC"]
1900_EXIT["1900-EXIT"]
1999_EXIT["1999-EXIT"]
2000_XREFFILE_PROC["2000-XREFFILE-PROC"]
2900_EXIT["2900-EXIT"]
2999_EXIT["2999-EXIT"]
3000_CUSTFILE_PROC["3000-CUSTFILE-PROC"]
3900_EXIT["3900-EXIT"]
3999_EXIT["3999-EXIT"]
4000_ACCTFILE_PROC["4000-ACCTFILE-PROC"]
4900_EXIT["4900-EXIT"]
4999_EXIT["4999-EXIT"]
0000_START --> 1000_TRNXFILE_PROC
0000_START --> 2000_XREFFILE_PROC
0000_START --> 3000_CUSTFILE_PROC
0000_START --> 4000_ACCTFILE_PROC
0000_START -.-> 9999_GOBACK
1000_TRNXFILE_PROC -.-> 1900_EXIT
2000_XREFFILE_PROC -.-> 2900_EXIT
3000_CUSTFILE_PROC -.-> 3900_EXIT
4000_ACCTFILE_PROC -.-> 4900_EXIT
Paragraphs
| Paragraph | Line | Performs |
|---|---|---|
| 0000-START | 116 | 1000-TRNXFILE-PROC, 2000-XREFFILE-PROC, 3000-CUSTFILE-PROC, 4000-ACCTFILE-PROC |
| 9999-GOBACK | 130 | |
| 1000-TRNXFILE-PROC | 133 | |
| 1900-EXIT | 151 | |
| 1999-EXIT | 154 | |
| 2000-XREFFILE-PROC | 157 | |
| 2900-EXIT | 175 | |
| 2999-EXIT | 178 | |
| 3000-CUSTFILE-PROC | 181 | |
| 3900-EXIT | 200 | |
| 3999-EXIT | 203 | |
| 4000-ACCTFILE-PROC | 206 | |
| 4900-EXIT | 225 | |
| 4999-EXIT | 228 |