Skip to content

CBCUS01C

Source: cbl/CBCUS01C.cbl

Type: Batch program

CBCUS01C — Customer File Reader

Purpose

CBCUS01C is a batch COBOL program from the CardDemo application that reads a customer master file (VSAM KSDS) sequentially and prints (via DISPLAY) each customer record to the job log/output. It appears to be a simple diagnostic or extract utility for reviewing customer file contents rather than a program that performs any business calculations or updates. It is invoked as step READCUST.STEP05 in a batch job.

How it works

  1. Main flow (Procedure Division, unnamed top-level paragraph):
  2. Displays a start-of-execution message.
  3. Calls 0000-CUSTFILE-OPEN to open the customer file.
  4. Loops with PERFORM UNTIL END-OF-FILE = 'Y', calling 1000-CUSTFILE-GET-NEXT to read each record and displaying CUSTOMER-RECORD for every record successfully read.
  5. Calls 9000-CUSTFILE-CLOSE to close the file.
  6. Displays an end-of-execution message and terminates with GOBACK.

  7. 0000-CUSTFILE-OPEN — Opens CUSTFILE-FILE for input. Checks the file status; if not '00' (success), it sets an error result, displays the I/O status via Z-DISPLAY-IO-STATUS, and abends via Z-ABEND-PROGRAM.

  8. 1000-CUSTFILE-GET-NEXT — Reads the next record from CUSTFILE-FILE into CUSTOMER-RECORD (defined in copybook CVCUS01Y). It also performs a redundant DISPLAY CUSTOMER-RECORD inside this paragraph (the record is displayed here and again in the main loop — see "Things to know"). Status '00' means success; status '10' means end-of-file (sets END-OF-FILE to 'Y'); any other status triggers an error display and abend.

  9. 9000-CUSTFILE-CLOSE — Closes the file, checking status the same way as open; any failure leads to error display and abend.

  10. Z-ABEND-PROGRAM — Displays 'ABENDING PROGRAM', sets a hard-coded abend code (ABCODE = 999) and timing value (0), then calls the LE runtime service CEE3ABD to abnormally terminate the program.

  11. Z-DISPLAY-IO-STATUS — Formats and displays the VSAM file status for diagnostics. If the raw status is non-numeric or the first byte is '9' (indicating an extended/VSAM-specific status), it decodes the second status byte as a binary value into a 4-digit numeric display (NNNN); otherwise it simply zero-pads the two-character status into a 4-digit display.

Inputs & outputs

Name Type Description
CUSTFILE-FILE / DD CUSTFILE Input file (VSAM KSDS, indexed, sequential access) Customer master file. Record key is FD-CUST-ID (9-digit numeric). Record layout: 9-digit customer ID + 491-byte data field (FD-CUST-DATA).
CVCUS01Y Copybook Defines CUSTOMER-RECORD, the working-storage layout into which each customer record is read and displayed. Full field-level structure is not shown in the extracted source, so exact business fields within the customer record are undocumented here.
CEE3ABD External call (LE service) Used only for abnormal termination (abend) when a file I/O error occurs.
SYSOUT / console (DISPLAY) Output All customer records are printed via DISPLAY; this is effectively a "report" output, but no separate report file is defined in this program.

No SQL tables or CICS commands are used — this is a batch, non-CICS, non-DB2 program relying solely on VSAM file access.

Things to know

  • No error-tolerant design: any file status other than '00' (success) or '10' (EOF, only checked in the read paragraph) causes an immediate abend via CEE3ABD with hard-coded abend code 999. There is no retry or recovery logic.
  • Hard-coded abend values: ABCODE is always 999 and TIMING is always 0 in Z-ABEND-PROGRAM, regardless of the actual error — this makes it impossible to distinguish open/read/close failures from the abend code alone (though Z-DISPLAY-IO-STATUS prints the underlying file status before abending).
  • Duplicate record display: CUSTOMER-RECORD is displayed twice for each successfully read record — once inside 1000-CUSTFILE-GET-NEXT and again in the main paragraph's loop. This looks like a bug/redundancy rather than intentional double output, though it's confirmed by the source as written.
  • EOF handling relies on status '10': standard COBOL/VSAM convention, but if the file returns a different "no more records" status, the program would instead treat it as a fatal error and abend rather than complete normally.
  • File status decoding logic in Z-DISPLAY-IO-STATUS includes special-case handling for statuses starting with '9' (extended VSAM status codes), decoding the second byte as a binary number — this logic is somewhat obscure and worth flagging for anyone modernizing file status handling.
  • No SQL or CICS usage — confirms this is a straightforward batch VSAM read program, simplifying any modernization/migration analysis (no transaction management or database concerns).
  • Business meaning of customer fields is unknown from this program alone — since CUSTOMER-RECORD's detailed structure comes from copybook CVCUS01Y (not included in the parsed facts or source shown), the specific customer attributes being read/displayed cannot be confirmed here.

Files

Logical file DD name
CUSTFILE-FILE CUSTFILE

Copybooks

CVCUS01Y

Calls

CEE3ABD

Executed by

READCUST.STEP05

Paragraph flow

flowchart TD
    1000_CUSTFILE_GET_NEXT["1000-CUSTFILE-GET-NEXT"]
    0000_CUSTFILE_OPEN["0000-CUSTFILE-OPEN"]
    9000_CUSTFILE_CLOSE["9000-CUSTFILE-CLOSE"]
    Z_ABEND_PROGRAM["Z-ABEND-PROGRAM"]
    Z_DISPLAY_IO_STATUS["Z-DISPLAY-IO-STATUS"]
    0000_CUSTFILE_OPEN --> Z_ABEND_PROGRAM
    0000_CUSTFILE_OPEN --> Z_DISPLAY_IO_STATUS
    1000_CUSTFILE_GET_NEXT --> Z_ABEND_PROGRAM
    1000_CUSTFILE_GET_NEXT --> Z_DISPLAY_IO_STATUS
    9000_CUSTFILE_CLOSE --> Z_ABEND_PROGRAM
    9000_CUSTFILE_CLOSE --> Z_DISPLAY_IO_STATUS

Paragraphs

Paragraph Line Performs
1000-CUSTFILE-GET-NEXT 92 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
0000-CUSTFILE-OPEN 118 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
9000-CUSTFILE-CLOSE 136 Z-DISPLAY-IO-STATUS, Z-ABEND-PROGRAM
Z-ABEND-PROGRAM 154
Z-DISPLAY-IO-STATUS 161