Skip to content

CBEXPORT

Source: cbl/CBEXPORT.cbl

Type: Batch program

CBEXPORT — Customer Data Export for Branch Migration

Purpose

CBEXPORT is a batch COBOL program that extracts customer, account, cross-reference, transaction, and card data from CardDemo's normalized VSAM files and writes them into a single, flat "multi-record" export file. This file is intended to support branch migration efforts, where a downstream system or process ingests a consolidated feed of customer data. The output uses a common record layout with a type code so that different entity types can share one physical file.

How it works

Processing is driven by 0000-MAIN-PROCESSING, which runs each stage in sequence and then ends with GOBACK:

  1. 1000-INITIALIZE
  2. Calls 1050-GENERATE-TIMESTAMP to capture the current date/time via ACCEPT ... FROM DATE YYYYMMDD and ACCEPT ... FROM TIME, then builds three derived fields: WS-EXPORT-DATE (YYYY-MM-DD), WS-EXPORT-TIME (HH:MM:SS), and a 26-character WS-FORMATTED-TIMESTAMP (date time.00) used as the timestamp stamped on every export record.
  3. Calls 1100-OPEN-FILES to open all five input files and the output file. Any non-zero file status on open triggers 9999-ABEND-PROGRAM.

  4. 2000-EXPORT-CUSTOMERS — reads CUSTOMER-INPUT sequentially (2100-READ-CUSTOMER-RECORD), and for each record calls 2200-CREATE-CUSTOMER-EXP-REC, which builds an export record (type 'C') and writes it out. Loop continues UNTIL WS-CUSTOMER-EOF.

  5. 3000-EXPORT-ACCOUNTS — same read/build/write pattern for ACCOUNT-INPUT, producing type 'A' records via 3200-CREATE-ACCOUNT-EXP-REC.

  6. 4000-EXPORT-XREFS — same pattern for XREF-INPUT, producing type 'X' records via 4200-CREATE-XREF-EXPORT-RECORD.

  7. 5000-EXPORT-TRANSACTIONS — same pattern for TRANSACTION-INPUT, producing type 'T' records via 5200-CREATE-TRAN-EXP-REC.

  8. 5500-EXPORT-CARDS — same pattern for CARD-INPUT, producing type 'D' records via 5700-CREATE-CARD-EXPORT-RECORD.

  9. 6000-FINALIZE — closes all six files and displays final counts for each record type plus a grand total.

Each of the five "create export record" paragraphs follows an identical pattern: INITIALIZE EXPORT-RECORD, set the record type code, stamp the timestamp, increment and assign a global sequence number (WS-SEQUENCE-COUNTEREXPORT-SEQUENCE-NUM), hard-code branch/region values, map source fields into the export layout, WRITE the record, check the write status (abend on failure), and bump both the entity-specific and total counters.

Any file read or write error (status not '00', and for reads not '10'/EOF either) causes an immediate call to 9999-ABEND-PROGRAM, which displays a message and invokes CALL 'CEE3ABD' (a LE abend routine) — there is no recovery or retry logic anywhere in the program.

Inputs & outputs

File / DD Select name Copybook Purpose
CUSTFILE CUSTOMER-INPUT CVCUS01Y Indexed input of customer profile records (keyed on CUST-ID), read sequentially, source for type 'C' export records
ACCTFILE ACCOUNT-INPUT CVACT01Y Indexed input of account records (keyed on ACCT-ID), source for type 'A' export records
XREFFILE XREF-INPUT CVACT03Y Indexed input of card/customer/account cross-reference records (keyed on XREF-CARD-NUM), source for type 'X' export records
TRANSACT TRANSACTION-INPUT CVTRA05Y Indexed input of transaction records (keyed on TRAN-ID), source for type 'T' export records
CARDFILE CARD-INPUT CVACT02Y Indexed input of card records (keyed on CARD-NUM), source for type 'D' export records
EXPFILE EXPORT-OUTPUT CVEXPORT (via EXPORT-RECORD) Indexed output, fixed 500-byte records, keyed on EXPORT-SEQUENCE-NUM; holds all five record types interleaved by processing order (all customers, then all accounts, then xrefs, then transactions, then cards)

No SQL tables or CICS commands are involved — this is a straight batch, file-to-file COBOL program (confirmed by the empty cics_commands/sql_tables lists). It is executed as CBEXPORT.STEP02 in its batch job.

Things to know

  • All five inputs are declared ORGANIZATION IS INDEXED, ACCESS MODE IS SEQUENTIAL. The program reads each file straight through in physical/key sequence with plain READ statements — there's no keyed random access or join logic. Records across files are not correlated to each other during export; customers, accounts, xrefs, transactions, and cards are each read and written independently in their own pass, so the resulting export file just concatenates five separate record streams by type, not a per-customer bundled record.

  • Hard-coded values: Every export record sets EXPORT-BRANCH-ID to '0001' and EXPORT-REGION-CODE to 'NORTH', regardless of the actual customer/account data. This strongly suggests a single-branch/region assumption baked into the code — worth flagging if this program is ever used for multi-branch data.

  • Global sequence counter: WS-SEQUENCE-COUNTER is a single counter (PIC 9(09)) incremented across all record types and used as the EXPORT-SEQUENCE-NUM (the output file's record key). Since output is ORGANIZATION IS INDEXED keyed on this field, and the field is assigned sequentially, duplicate key errors are unlikely under normal operation, but there's no explicit duplicate-key handling shown.

  • Fail-fast error handling: Every file open, read, and write operation checks its FILE STATUS field. Any unexpected status (not '00' for OK, not '10' for EOF where applicable) results in a DISPLAY of the error and an immediate hard abend via CALL 'CEE3ABD' in 9999-ABEND-PROGRAM. There is no partial-output cleanup, rollback, or restart/checkpoint logic — a failure partway through leaves the export file incomplete.

  • Timestamp construction is manual, not using intrinsic functions. 1050-GENERATE-TIMESTAMP builds date/time strings via STRING concatenation of numeric subfields; this assumes the numeric picture clauses always produce fixed-width zero-padded output, which should hold given the PIC 9(0n) definitions, but there's no explicit validation of the ACCEPT results.

  • No parameterization observed: branch ID, region code, and file assignment names are all fixed in the source. Any change to these values (e.g., supporting multiple branches or regions) would require a code change, not a configuration change.

  • Copybook CVEXPORT defines the EXPORT-RECORD structure shared by all five record-creation paragraphs; its exact layout wasn't included in the source provided, so field sizes/subscripts (e.g., EXP-CUST-ADDR-LINE(1..3), EXP-CUST-PHONE-NUM(1..2)) are assumed correct per copybook but not independently verified here.

Files

Logical file DD name
CUSTOMER-INPUT CUSTFILE
ACCOUNT-INPUT ACCTFILE
XREF-INPUT XREFFILE
TRANSACTION-INPUT TRANSACT
CARD-INPUT CARDFILE
EXPORT-OUTPUT EXPFILE

Copybooks

CVACT01Y, CVACT02Y, CVACT03Y, CVCUS01Y, CVEXPORT, CVTRA05Y

Calls

CEE3ABD

Executed by

CBEXPORT.STEP02

Paragraph flow

flowchart TD
    0000_MAIN_PROCESSING["0000-MAIN-PROCESSING"]
    1000_INITIALIZE["1000-INITIALIZE"]
    1050_GENERATE_TIMESTAMP["1050-GENERATE-TIMESTAMP"]
    1100_OPEN_FILES["1100-OPEN-FILES"]
    2000_EXPORT_CUSTOMERS["2000-EXPORT-CUSTOMERS"]
    2100_READ_CUSTOMER_RECORD["2100-READ-CUSTOMER-RECORD"]
    2200_CREATE_CUSTOMER_EXP_REC["2200-CREATE-CUSTOMER-EXP-REC"]
    3000_EXPORT_ACCOUNTS["3000-EXPORT-ACCOUNTS"]
    3100_READ_ACCOUNT_RECORD["3100-READ-ACCOUNT-RECORD"]
    3200_CREATE_ACCOUNT_EXP_REC["3200-CREATE-ACCOUNT-EXP-REC"]
    4000_EXPORT_XREFS["4000-EXPORT-XREFS"]
    4100_READ_XREF_RECORD["4100-READ-XREF-RECORD"]
    4200_CREATE_XREF_EXPORT_RECORD["4200-CREATE-XREF-EXPORT-RECORD"]
    5000_EXPORT_TRANSACTIONS["5000-EXPORT-TRANSACTIONS"]
    5100_READ_TRANSACTION_RECORD["5100-READ-TRANSACTION-RECORD"]
    5200_CREATE_TRAN_EXP_REC["5200-CREATE-TRAN-EXP-REC"]
    5500_EXPORT_CARDS["5500-EXPORT-CARDS"]
    5600_READ_CARD_RECORD["5600-READ-CARD-RECORD"]
    5700_CREATE_CARD_EXPORT_RECORD["5700-CREATE-CARD-EXPORT-RECORD"]
    6000_FINALIZE["6000-FINALIZE"]
    9999_ABEND_PROGRAM["9999-ABEND-PROGRAM"]
    0000_MAIN_PROCESSING --> 1000_INITIALIZE
    0000_MAIN_PROCESSING --> 2000_EXPORT_CUSTOMERS
    0000_MAIN_PROCESSING --> 3000_EXPORT_ACCOUNTS
    0000_MAIN_PROCESSING --> 4000_EXPORT_XREFS
    0000_MAIN_PROCESSING --> 5000_EXPORT_TRANSACTIONS
    0000_MAIN_PROCESSING --> 5500_EXPORT_CARDS
    0000_MAIN_PROCESSING --> 6000_FINALIZE
    1000_INITIALIZE --> 1050_GENERATE_TIMESTAMP
    1000_INITIALIZE --> 1100_OPEN_FILES
    1100_OPEN_FILES --> 9999_ABEND_PROGRAM
    2000_EXPORT_CUSTOMERS --> 2100_READ_CUSTOMER_RECORD
    2000_EXPORT_CUSTOMERS --> 2200_CREATE_CUSTOMER_EXP_REC
    2100_READ_CUSTOMER_RECORD --> 9999_ABEND_PROGRAM
    2200_CREATE_CUSTOMER_EXP_REC --> 9999_ABEND_PROGRAM
    3000_EXPORT_ACCOUNTS --> 3100_READ_ACCOUNT_RECORD
    3000_EXPORT_ACCOUNTS --> 3200_CREATE_ACCOUNT_EXP_REC
    3100_READ_ACCOUNT_RECORD --> 9999_ABEND_PROGRAM
    3200_CREATE_ACCOUNT_EXP_REC --> 9999_ABEND_PROGRAM
    4000_EXPORT_XREFS --> 4100_READ_XREF_RECORD
    4000_EXPORT_XREFS --> 4200_CREATE_XREF_EXPORT_RECORD
    4100_READ_XREF_RECORD --> 9999_ABEND_PROGRAM
    4200_CREATE_XREF_EXPORT_RECORD --> 9999_ABEND_PROGRAM
    5000_EXPORT_TRANSACTIONS --> 5100_READ_TRANSACTION_RECORD
    5000_EXPORT_TRANSACTIONS --> 5200_CREATE_TRAN_EXP_REC
    5100_READ_TRANSACTION_RECORD --> 9999_ABEND_PROGRAM
    5200_CREATE_TRAN_EXP_REC --> 9999_ABEND_PROGRAM
    5500_EXPORT_CARDS --> 5600_READ_CARD_RECORD
    5500_EXPORT_CARDS --> 5700_CREATE_CARD_EXPORT_RECORD
    5600_READ_CARD_RECORD --> 9999_ABEND_PROGRAM
    5700_CREATE_CARD_EXPORT_RECORD --> 9999_ABEND_PROGRAM

Paragraphs

Paragraph Line Performs
0000-MAIN-PROCESSING 149 1000-INITIALIZE, 2000-EXPORT-CUSTOMERS, 3000-EXPORT-ACCOUNTS, 4000-EXPORT-XREFS, 5000-EXPORT-TRANSACTIONS, 5500-EXPORT-CARDS
1000-INITIALIZE 161 1050-GENERATE-TIMESTAMP, 1100-OPEN-FILES
1050-GENERATE-TIMESTAMP 172
1100-OPEN-FILES 198 9999-ABEND-PROGRAM, 9999-ABEND-PROGRAM, 9999-ABEND-PROGRAM, 9999-ABEND-PROGRAM, 9999-ABEND-PROGRAM, 9999-ABEND-PROGRAM
2000-EXPORT-CUSTOMERS 243 2100-READ-CUSTOMER-RECORD, 2200-CREATE-CUSTOMER-EXP-REC, 2100-READ-CUSTOMER-RECORD
2100-READ-CUSTOMER-RECORD 258 9999-ABEND-PROGRAM
2200-CREATE-CUSTOMER-EXP-REC 269 9999-ABEND-PROGRAM
3000-EXPORT-ACCOUNTS 312 3100-READ-ACCOUNT-RECORD, 3200-CREATE-ACCOUNT-EXP-REC, 3100-READ-ACCOUNT-RECORD
3100-READ-ACCOUNT-RECORD 327 9999-ABEND-PROGRAM
3200-CREATE-ACCOUNT-EXP-REC 338 9999-ABEND-PROGRAM
4000-EXPORT-XREFS 376 4100-READ-XREF-RECORD, 4200-CREATE-XREF-EXPORT-RECORD, 4100-READ-XREF-RECORD
4100-READ-XREF-RECORD 391 9999-ABEND-PROGRAM
4200-CREATE-XREF-EXPORT-RECORD 402 9999-ABEND-PROGRAM
5000-EXPORT-TRANSACTIONS 431 5100-READ-TRANSACTION-RECORD, 5200-CREATE-TRAN-EXP-REC, 5100-READ-TRANSACTION-RECORD
5100-READ-TRANSACTION-RECORD 446 9999-ABEND-PROGRAM
5200-CREATE-TRAN-EXP-REC 457 9999-ABEND-PROGRAM
5500-EXPORT-CARDS 496 5600-READ-CARD-RECORD, 5700-CREATE-CARD-EXPORT-RECORD, 5600-READ-CARD-RECORD
5600-READ-CARD-RECORD 511 9999-ABEND-PROGRAM
5700-CREATE-CARD-EXPORT-RECORD 522 9999-ABEND-PROGRAM
6000-FINALIZE 554
9999-ABEND-PROGRAM 576