Skip to content

CBTRN01C

Source: cbl/CBTRN01C.cbl

Type: Batch program

CBTRN01C — Daily Transaction Posting/Validation Program

Purpose

CBTRN01C is a batch COBOL program from the CardDemo application that reads a daily transaction file and validates each transaction against the card cross-reference and account master files. For every transaction it looks up the card number in the cross-reference file to find the associated account, then confirms that account exists in the account master. It does not appear to actually post/update any records (despite the header comment "Post the records from daily transaction file") — as written, it only reads, validates, and displays results; no records are written or rewritten.

How it works

  1. MAIN-PARA displays a start message, then opens all six files in sequence via 0000-DALYTRAN-OPEN through 0500-TRANFILE-OPEN.
  2. It then loops (PERFORM UNTIL END-OF-DAILY-TRANS-FILE = 'Y'):
  3. 1000-DALYTRAN-GET-NEXT reads the next record from the daily transaction file. A file status of '10' sets the end-of-file flag; any other non-'00' status triggers an abend.
  4. If a record was read, it is displayed (DISPLAY DALYTRAN-RECORD).
  5. The card number from the transaction is moved to the XREF key and 2000-LOOKUP-XREF does a keyed random read of the cross-reference file. Success or failure (invalid key) is tracked in WS-XREF-READ-STATUS.
  6. If the XREF lookup succeeded, the resolved account ID is moved to the account key and 3000-READ-ACCOUNT does a keyed random read of the account master file. If not found, a message is displayed (ACCOUNT <id> NOT FOUND).
  7. If the XREF lookup failed, a message is displayed and the transaction is skipped (CARD NUMBER ... COULD NOT BE VERIFIED. SKIPPING TRANSACTION ID-...).
  8. After the loop ends, all files are closed via 9000-DALYTRAN-CLOSE through 9500-TRANFILE-CLOSE, and an end-of-execution message is displayed before GOBACK.
  9. Every open/read/close operation checks its file status and, on unexpected errors, calls Z-DISPLAY-IO-STATUS (formats and displays the status code) followed by Z-ABEND-PROGRAM, which invokes the CEE3ABD language-environment abend service with a fixed abend code of 999.

Note: the CARD-FILE (CARDFILE) and TRANSACT-FILE (TRANFILE) are opened and closed but are never read or written anywhere in the procedure logic shown — they appear unused in this program's processing flow.

Inputs & outputs

File / DD Access Purpose
DALYTRAN-FILE (DD DALYTRAN) Sequential, input Daily transaction input; read one record at a time (FD-TRAN-RECORD — 16-byte transaction ID + 334-byte data, mapped via copybook CVTRA06Y structure DALYTRAN-RECORD).
XREF-FILE (DD XREFFILE) Indexed, random, input Card-to-account/customer cross-reference; keyed read by FD-XREF-CARD-NUM (copybook CVACT03Y) to resolve XREF-ACCT-ID and XREF-CUST-ID from the card number.
ACCOUNT-FILE (DD ACCTFILE) Indexed, random, input Account master; keyed read by FD-ACCT-ID (copybook CVACT01Y) to validate that the account resolved from XREF actually exists.
CUSTOMER-FILE (DD CUSTFILE) Indexed, random, input Opened/closed only; copybook CVCUS01Y defines its layout, but no read is performed in the procedure logic.
CARD-FILE (DD CARDFILE) Indexed, random, input Opened/closed only (copybook CVACT02Y); not read/used in this program's logic.
TRANSACT-FILE (DD TRANFILE) Indexed, random, input Opened/closed only (copybook CVTRA05Y); not read/used in this program's logic.

No SQL tables and no CICS commands are used — this is a plain batch/QSAM+VSAM program. The only external call is to CEE3ABD (Language Environment abend routine).

Things to know

  • No actual update/posting logic: despite the program header stating "Post the records from daily transaction file," the code only reads and validates — there are no WRITE/REWRITE statements. If this program is meant to post transactions to the account/customer files, that logic is missing or handled elsewhere (possibly a later program in the CardDemo suite, e.g., CBTRN02C).
  • Unused files opened: CUSTOMER-FILE, CARD-FILE, and TRANSACT-FILE are opened and closed but never read. This could be leftover scaffolding, a template copied from another program, or files intended for future/other use — worth confirming with the file DD assignments in the JCL before assuming they're dead weight.
  • Hard-coded abend code: Z-ABEND-PROGRAM always sets ABCODE to 999 regardless of which file/operation failed — the actual failing file's status is displayed just before the abend (via Z-DISPLAY-IO-STATUS), so root cause must be found in the DISPLAY output/job log, not the abend code itself.
  • Close-error messages point to the wrong file: in 9000-DALYTRAN-CLOSE, the error DISPLAY says 'ERROR CLOSING CUSTOMER FILE' and moves CUSTFILE-STATUS (not DALYTRAN-STATUS) to IO-STATUS — this looks like a copy-paste bug, since the paragraph is closing DALYTRAN-FILE. Similarly, 9100-CUSTFILE-CLOSE also displays 'ERROR CLOSING CUSTOMER FILE' (which is correct there). Anyone debugging a DALYTRAN close failure should be aware the displayed message/status may be misleading.
  • File status handling: Only status '00' (success) and '10' (end-of-file, checked only for DALYTRAN reads) are treated as non-fatal; every other status on open/read/close causes an immediate abend via CEE3ABD — there is no retry or recovery logic.
  • APPL-RESULT initialization inconsistency: open paragraphs set APPL-RESULT via MOVE 8, while close paragraphs use ADD 8 TO ZERO GIVING APPL-RESULT — functionally equivalent but stylistically inconsistent, suggesting copy/paste across paragraphs without cleanup.
  • Skipped transactions are not logged to an output file — when a card can't be verified via XREF, or an account isn't found, the only trace is a DISPLAY statement (console/job log), with no reject file or return-code signaling for downstream monitoring.
  • Copybooks: record layouts for all six files and key working-storage fields come from copybooks CVACT01Y, CVACT02Y, CVACT03Y, CVCUS01Y, CVTRA05Y, CVTRA06Y — field-level detail (e.g., full transaction/account/customer layouts) is defined there, not in this source file.

Files

Logical file DD name
DALYTRAN-FILE DALYTRAN
CUSTOMER-FILE CUSTFILE
XREF-FILE XREFFILE
CARD-FILE CARDFILE
ACCOUNT-FILE ACCTFILE
TRANSACT-FILE TRANFILE

Copybooks

CVACT01Y, CVACT02Y, CVACT03Y, CVCUS01Y, CVTRA05Y, CVTRA06Y

Calls

CEE3ABD

Paragraph flow

flowchart TD
    MAIN_PARA["MAIN-PARA"]
    1000_DALYTRAN_GET_NEXT["1000-DALYTRAN-GET-NEXT"]
    2000_LOOKUP_XREF["2000-LOOKUP-XREF"]
    3000_READ_ACCOUNT["3000-READ-ACCOUNT"]
    0000_DALYTRAN_OPEN["0000-DALYTRAN-OPEN"]
    0100_CUSTFILE_OPEN["0100-CUSTFILE-OPEN"]
    0200_XREFFILE_OPEN["0200-XREFFILE-OPEN"]
    0300_CARDFILE_OPEN["0300-CARDFILE-OPEN"]
    0400_ACCTFILE_OPEN["0400-ACCTFILE-OPEN"]
    0500_TRANFILE_OPEN["0500-TRANFILE-OPEN"]
    9000_DALYTRAN_CLOSE["9000-DALYTRAN-CLOSE"]
    9100_CUSTFILE_CLOSE["9100-CUSTFILE-CLOSE"]
    9200_XREFFILE_CLOSE["9200-XREFFILE-CLOSE"]
    9300_CARDFILE_CLOSE["9300-CARDFILE-CLOSE"]
    9400_ACCTFILE_CLOSE["9400-ACCTFILE-CLOSE"]
    9500_TRANFILE_CLOSE["9500-TRANFILE-CLOSE"]
    Z_ABEND_PROGRAM["Z-ABEND-PROGRAM"]
    Z_DISPLAY_IO_STATUS["Z-DISPLAY-IO-STATUS"]
    0000_DALYTRAN_OPEN --> Z_ABEND_PROGRAM
    0000_DALYTRAN_OPEN --> Z_DISPLAY_IO_STATUS
    0100_CUSTFILE_OPEN --> Z_ABEND_PROGRAM
    0100_CUSTFILE_OPEN --> Z_DISPLAY_IO_STATUS
    0200_XREFFILE_OPEN --> Z_ABEND_PROGRAM
    0200_XREFFILE_OPEN --> Z_DISPLAY_IO_STATUS
    0300_CARDFILE_OPEN --> Z_ABEND_PROGRAM
    0300_CARDFILE_OPEN --> Z_DISPLAY_IO_STATUS
    0400_ACCTFILE_OPEN --> Z_ABEND_PROGRAM
    0400_ACCTFILE_OPEN --> Z_DISPLAY_IO_STATUS
    0500_TRANFILE_OPEN --> Z_ABEND_PROGRAM
    0500_TRANFILE_OPEN --> Z_DISPLAY_IO_STATUS
    1000_DALYTRAN_GET_NEXT --> Z_ABEND_PROGRAM
    1000_DALYTRAN_GET_NEXT --> Z_DISPLAY_IO_STATUS
    9000_DALYTRAN_CLOSE --> Z_ABEND_PROGRAM
    9000_DALYTRAN_CLOSE --> Z_DISPLAY_IO_STATUS
    9100_CUSTFILE_CLOSE --> Z_ABEND_PROGRAM
    9100_CUSTFILE_CLOSE --> Z_DISPLAY_IO_STATUS
    9200_XREFFILE_CLOSE --> Z_ABEND_PROGRAM
    9200_XREFFILE_CLOSE --> Z_DISPLAY_IO_STATUS
    9300_CARDFILE_CLOSE --> Z_ABEND_PROGRAM
    9300_CARDFILE_CLOSE --> Z_DISPLAY_IO_STATUS
    9400_ACCTFILE_CLOSE --> Z_ABEND_PROGRAM
    9400_ACCTFILE_CLOSE --> Z_DISPLAY_IO_STATUS
    9500_TRANFILE_CLOSE --> Z_ABEND_PROGRAM
    9500_TRANFILE_CLOSE --> Z_DISPLAY_IO_STATUS
    MAIN_PARA --> 0000_DALYTRAN_OPEN
    MAIN_PARA --> 0100_CUSTFILE_OPEN
    MAIN_PARA --> 0200_XREFFILE_OPEN
    MAIN_PARA --> 0300_CARDFILE_OPEN
    MAIN_PARA --> 0400_ACCTFILE_OPEN
    MAIN_PARA --> 0500_TRANFILE_OPEN
    MAIN_PARA --> 1000_DALYTRAN_GET_NEXT
    MAIN_PARA --> 2000_LOOKUP_XREF
    MAIN_PARA --> 3000_READ_ACCOUNT
    MAIN_PARA --> 9000_DALYTRAN_CLOSE
    MAIN_PARA --> 9100_CUSTFILE_CLOSE
    MAIN_PARA --> 9200_XREFFILE_CLOSE
    MAIN_PARA --> 9300_CARDFILE_CLOSE
    MAIN_PARA --> 9400_ACCTFILE_CLOSE
    MAIN_PARA --> 9500_TRANFILE_CLOSE

Paragraphs

Paragraph Line Performs
MAIN-PARA 155 0000-DALYTRAN-OPEN, 0100-CUSTFILE-OPEN, 0200-XREFFILE-OPEN, 0300-CARDFILE-OPEN, 0400-ACCTFILE-OPEN, 0500-TRANFILE-OPEN
1000-DALYTRAN-GET-NEXT 202 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
2000-LOOKUP-XREF 227
3000-READ-ACCOUNT 241
0000-DALYTRAN-OPEN 252 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
0100-CUSTFILE-OPEN 271 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
0200-XREFFILE-OPEN 289 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
0300-CARDFILE-OPEN 307 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
0400-ACCTFILE-OPEN 325 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
0500-TRANFILE-OPEN 343 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
9000-DALYTRAN-CLOSE 361 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
9100-CUSTFILE-CLOSE 379 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
9200-XREFFILE-CLOSE 397 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
9300-CARDFILE-CLOSE 415 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
9400-ACCTFILE-CLOSE 433 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
9500-TRANFILE-CLOSE 451 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
Z-ABEND-PROGRAM 469
Z-DISPLAY-IO-STATUS 476