CBIMPORT
Source: cbl/CBIMPORT.cbl
Type: Batch program
CBIMPORT — Customer Data Import from Branch Migration Export
Purpose
CBIMPORT is a batch COBOL program that imports customer data from a "branch migration" export file into the CardDemo application's normalized file structure. It reads a single multi-record-type input file and splits its contents into separate flat files for customers, accounts, card-cross-references, transactions, and cards, based on a record-type code found in each input record. Records with an unrecognized type are logged to a separate error file rather than causing the job to fail.
How it works
Processing is driven by 0000-MAIN-PROCESSING, which calls four stages in sequence: 1000-INITIALIZE, 2000-PROCESS-EXPORT-FILE, 3000-VALIDATE-IMPORT, and 4000-FINALIZE, then ends the program with GOBACK.
- Initialization (
1000-INITIALIZE) — Displays a start message, derives an import date/time stamp fromFUNCTION CURRENT-DATE, and calls1100-OPEN-FILESto open the input file and all six output files. - Main read loop (
2000-PROCESS-EXPORT-FILE) — Reads the first export record via2100-READ-EXPORT-RECORD, then loops (PERFORM UNTIL WS-EXPORT-EOF) reading and dispatching each record until end-of-file, incrementingWS-TOTAL-RECORDS-READfor each record read. - Record dispatch (
2200-PROCESS-RECORD-BY-TYPE) — ExaminesEXPORT-REC-TYPEand routes to one of six paragraphs based on a single-character code: 'C'→2300-PROCESS-CUSTOMER-RECORD'A'→2400-PROCESS-ACCOUNT-RECORD'X'→2500-PROCESS-XREF-RECORD'T'→2600-PROCESS-TRAN-RECORD'D'→2650-PROCESS-CARD-RECORD- anything else →
2700-PROCESS-UNKNOWN-RECORD - Per-type mapping paragraphs (2300/2400/2500/2600/2650) — Each
INITIALIZEs its target record, moves individual fields from theEXPORT-RECORDlayout (from copybookCVEXPORT) into the corresponding output record layout (customer, account, xref, transaction, or card),WRITEs the record, checks the file status, and increments a per-type counter (e.g.,WS-CUSTOMER-RECORDS-IMPORTED). - Unknown records (
2700-PROCESS-UNKNOWN-RECORD→2750-WRITE-ERROR) — IncrementsWS-UNKNOWN-RECORD-TYPE-COUNT, builds an error record (timestamp, record type, sequence number, fixed message text) and writes it to the error file via2750-WRITE-ERROR, which also incrementsWS-ERROR-RECORDS-WRITTEN. - Validation (
3000-VALIDATE-IMPORT) — Currently just displays two static messages ("Import validation completed" / "No validation errors detected"); it does not perform any actual data validation despite the paragraph name and the header comment's claim of "checksum" validation. - Finalize (
4000-FINALIZE) — Closes all seven files and displays a summary of statistics: total records read, and counts imported/written per record type/error.
Inputs & outputs
| File / Select | DD Name | Direction | Purpose |
|---|---|---|---|
| EXPORT-INPUT | EXPFILE | Input | Multi-record-type export file (500-byte records); layout defined by copybook CVEXPORT. Declared as INDEXED with a RECORD KEY (EXPORT-SEQUENCE-NUM) but accessed sequentially. |
| CUSTOMER-OUTPUT | CUSTOUT | Output | Normalized customer records (500 bytes), layout from CVCUS01Y. |
| ACCOUNT-OUTPUT | ACCTOUT | Output | Normalized account records (300 bytes), layout from CVACT01Y. |
| XREF-OUTPUT | XREFOUT | Output | Card-to-customer/account cross-reference records (50 bytes), layout from CVACT03Y. |
| TRANSACTION-OUTPUT | TRNXOUT | Output | Transaction records (350 bytes), layout from CVTRA05Y. |
| CARD-OUTPUT | CARDOUT | Output | Card records (150 bytes), layout from CVACT02Y. |
| ERROR-OUTPUT | ERROUT | Output | Error/rejection log (132 bytes) for records with an unrecognized record-type code. |
Copybooks used: CVACT01Y, CVACT02Y, CVACT03Y, CVCUS01Y, CVEXPORT, CVTRA05Y. No CICS commands or SQL tables are used — this is a pure batch, file-to-file program (executed as job step CBIMPORT.STEP01).
Things to know
- No SQL/CICS involvement — this program only reads/writes flat files; there is no database interaction to model when modernizing.
- Aggressive error handling (fail-fast) — Any file-open failure, any read error (other than EOF), or any write failure on the customer, account, xref, transaction, or card outputs immediately triggers
9999-ABEND-PROGRAM, which callsCEE3ABD(a LE abend routine) and terminates the job. There is no retry or partial-recovery logic — a single bad write anywhere aborts the whole import. - Inconsistent error handling for the error file itself — Unlike the other outputs, a failure writing to
ERROR-OUTPUTin2750-WRITE-ERRORis only displayed, not abended; the program continues processing. - "Validation" is a no-op —
3000-VALIDATE-IMPORTonly prints static "success" messages; despite the program header's stated business goal of "Validate data integrity using checksums," no actual checksum or integrity validation logic exists in the code as extracted. Documentation/business expectations may be out of sync with the actual implementation. - Unknown record types are tolerated, not fatal — Any record whose type code isn't C/A/X/T/D is logged to the error file with a fixed message ("Unknown record type encountered") and processing continues; these are not counted as failures for abend purposes.
- Hard-coded layout assumptions — Field-level mapping between
EXPORT-RECORD(fromCVEXPORT) and each target record is done via direct one-to-oneMOVEstatements; any mismatch in copybook definitions between the export layout and target layouts would silently truncate/misalign data rather than raise an error. - EXPORT-INPUT is declared INDEXED with a key but read sequentially — the
SELECTclause specifiesORGANIZATION IS INDEXEDwithRECORD KEY IS EXPORT-SEQUENCE-NUM, yet the access mode is SEQUENTIAL and processing simply reads until EOF; this is unusual for a plain import file and worth confirming with the team whether indexed access was intended elsewhere. - Statistics are display-only — Counts (records read, per-type imported, errors, unknown types) are only written to
DISPLAY(job log) output at the end of the run; there's no separate report file or return code differentiation based on these counts. - No non-zero return code logic observed — Aside from the abend path, the program does not appear to set an explicit
RETURN-CODEfor partial success/failure scenarios like unknown records or error-file write failures; downstream job steps relying on condition codes should be reviewed against actual runtime behavior.
Files
| Logical file | DD name |
|---|---|
| EXPORT-INPUT | EXPFILE |
| CUSTOMER-OUTPUT | CUSTOUT |
| ACCOUNT-OUTPUT | ACCTOUT |
| XREF-OUTPUT | XREFOUT |
| TRANSACTION-OUTPUT | TRNXOUT |
| CARD-OUTPUT | CARDOUT |
| ERROR-OUTPUT | ERROUT |
Copybooks
CVACT01Y, CVACT02Y, CVACT03Y, CVCUS01Y, CVEXPORT, CVTRA05Y
Calls
CEE3ABD
Executed by
CBIMPORT.STEP01
Paragraph flow
flowchart TD
0000_MAIN_PROCESSING["0000-MAIN-PROCESSING"]
1000_INITIALIZE["1000-INITIALIZE"]
1100_OPEN_FILES["1100-OPEN-FILES"]
2000_PROCESS_EXPORT_FILE["2000-PROCESS-EXPORT-FILE"]
2100_READ_EXPORT_RECORD["2100-READ-EXPORT-RECORD"]
2200_PROCESS_RECORD_BY_TYPE["2200-PROCESS-RECORD-BY-TYPE"]
2300_PROCESS_CUSTOMER_RECORD["2300-PROCESS-CUSTOMER-RECORD"]
2400_PROCESS_ACCOUNT_RECORD["2400-PROCESS-ACCOUNT-RECORD"]
2500_PROCESS_XREF_RECORD["2500-PROCESS-XREF-RECORD"]
2600_PROCESS_TRAN_RECORD["2600-PROCESS-TRAN-RECORD"]
2650_PROCESS_CARD_RECORD["2650-PROCESS-CARD-RECORD"]
2700_PROCESS_UNKNOWN_RECORD["2700-PROCESS-UNKNOWN-RECORD"]
2750_WRITE_ERROR["2750-WRITE-ERROR"]
3000_VALIDATE_IMPORT["3000-VALIDATE-IMPORT"]
4000_FINALIZE["4000-FINALIZE"]
9999_ABEND_PROGRAM["9999-ABEND-PROGRAM"]
0000_MAIN_PROCESSING --> 1000_INITIALIZE
0000_MAIN_PROCESSING --> 2000_PROCESS_EXPORT_FILE
0000_MAIN_PROCESSING --> 3000_VALIDATE_IMPORT
0000_MAIN_PROCESSING --> 4000_FINALIZE
1000_INITIALIZE --> 1100_OPEN_FILES
1100_OPEN_FILES --> 9999_ABEND_PROGRAM
2000_PROCESS_EXPORT_FILE --> 2100_READ_EXPORT_RECORD
2000_PROCESS_EXPORT_FILE --> 2200_PROCESS_RECORD_BY_TYPE
2100_READ_EXPORT_RECORD --> 9999_ABEND_PROGRAM
2200_PROCESS_RECORD_BY_TYPE --> 2300_PROCESS_CUSTOMER_RECORD
2200_PROCESS_RECORD_BY_TYPE --> 2400_PROCESS_ACCOUNT_RECORD
2200_PROCESS_RECORD_BY_TYPE --> 2500_PROCESS_XREF_RECORD
2200_PROCESS_RECORD_BY_TYPE --> 2600_PROCESS_TRAN_RECORD
2200_PROCESS_RECORD_BY_TYPE --> 2650_PROCESS_CARD_RECORD
2200_PROCESS_RECORD_BY_TYPE --> 2700_PROCESS_UNKNOWN_RECORD
2300_PROCESS_CUSTOMER_RECORD --> 9999_ABEND_PROGRAM
2400_PROCESS_ACCOUNT_RECORD --> 9999_ABEND_PROGRAM
2500_PROCESS_XREF_RECORD --> 9999_ABEND_PROGRAM
2600_PROCESS_TRAN_RECORD --> 9999_ABEND_PROGRAM
2650_PROCESS_CARD_RECORD --> 9999_ABEND_PROGRAM
2700_PROCESS_UNKNOWN_RECORD --> 2750_WRITE_ERROR
Paragraphs
| Paragraph | Line | Performs |
|---|---|---|
| 0000-MAIN-PROCESSING | 165 | 1000-INITIALIZE, 2000-PROCESS-EXPORT-FILE, 3000-VALIDATE-IMPORT, 4000-FINALIZE |
| 1000-INITIALIZE | 174 | 1100-OPEN-FILES |
| 1100-OPEN-FILES | 196 | 9999-ABEND-PROGRAM, 9999-ABEND-PROGRAM, 9999-ABEND-PROGRAM, 9999-ABEND-PROGRAM, 9999-ABEND-PROGRAM, 9999-ABEND-PROGRAM |
| 2000-PROCESS-EXPORT-FILE | 248 | 2100-READ-EXPORT-RECORD, 2200-PROCESS-RECORD-BY-TYPE, 2100-READ-EXPORT-RECORD |
| 2100-READ-EXPORT-RECORD | 259 | 9999-ABEND-PROGRAM |
| 2200-PROCESS-RECORD-BY-TYPE | 270 | 2300-PROCESS-CUSTOMER-RECORD, 2400-PROCESS-ACCOUNT-RECORD, 2500-PROCESS-XREF-RECORD, 2600-PROCESS-TRAN-RECORD, 2650-PROCESS-CARD-RECORD, 2700-PROCESS-UNKNOWN-RECORD |
| 2300-PROCESS-CUSTOMER-RECORD | 288 | 9999-ABEND-PROGRAM |
| 2400-PROCESS-ACCOUNT-RECORD | 323 | 9999-ABEND-PROGRAM |
| 2500-PROCESS-XREF-RECORD | 352 | 9999-ABEND-PROGRAM |
| 2600-PROCESS-TRAN-RECORD | 372 | 9999-ABEND-PROGRAM |
| 2650-PROCESS-CARD-RECORD | 402 | 9999-ABEND-PROGRAM |
| 2700-PROCESS-UNKNOWN-RECORD | 425 | 2750-WRITE-ERROR |
| 2750-WRITE-ERROR | 437 | |
| 3000-VALIDATE-IMPORT | 449 | |
| 4000-FINALIZE | 455 | |
| 9999-ABEND-PROGRAM | 481 |