Skip to content

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 inspects LK-M03B-DD (the target file/DD name) and dispatches to one of four paragraph ranges via EVALUATE:
  • 'TRNXFILE'1000-TRNXFILE-PROC thru 1999-EXIT
  • 'XREFFILE'2000-XREFFILE-PROC thru 2999-EXIT
  • 'CUSTFILE'3000-CUSTFILE-PROC thru 3999-EXIT
  • 'ACCTFILE'4000-ACCTFILE-PROC thru 4999-EXIT
  • Any other value falls through to 9999-GOBACK, ending the call with no action taken.

  • Each of the four xxx0-...-PROC paragraphs follows the same pattern, keyed off the operation flag LK-M03B-OPER (via 88-levels M03B-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-PROC and XREFFILE/2000-XREFFILE-PROC, matching their ACCESS MODE IS SEQUENTIAL).
  • READ-K ('K') — keyed random read (only supported for CUSTFILE/3000-CUSTFILE-PROC and ACCTFILE/4000-ACCTFILE-PROC, matching their ACCESS MODE IS RANDOM); the key is built by moving LK-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-byte FILE STATUS field into LK-M03B-RC for the caller to inspect, then falls into x999-EXIT (a bare EXIT) and returns to 9999-GOBACK/GOBACK.

  • The 88-levels M03B-WRITE and M03B-REWRITE are defined but no paragraph implements them — passing those operation codes results in none of the IF conditions matching, so the paragraph does nothing except fall through to move the (unchanged) file status into LK-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, or CLOSE statements have INVALID KEY, AT END, or NOT ON SIZE ERROR/error clauses. The only feedback to the caller is the raw file-status code copied into LK-M03B-RC after the fact — callers must check this themselves; the subroutine itself never branches on failure.
  • Silent no-op for unsupported operations. Requesting WRITE ('W') or REWRITE ('Z') — or a READ on the random-access files, or READ-K on the sequential files — matches none of the IF conditions 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-DD doesn't match one of the four expected values, EVALUATE ... WHEN OTHER jumps straight to 9999-GOBACK — no error is raised, and no status is returned in LK-M03B-RC.
  • All files opened INPUT only — this module is read-only despite the presence of WRITE/REWRITE operation 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