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
- Main flow (Procedure Division, unnamed top-level paragraph):
- Displays a start-of-execution message.
- Calls
0000-CUSTFILE-OPENto open the customer file. - Loops with
PERFORM UNTIL END-OF-FILE = 'Y', calling1000-CUSTFILE-GET-NEXTto read each record and displayingCUSTOMER-RECORDfor every record successfully read. - Calls
9000-CUSTFILE-CLOSEto close the file. -
Displays an end-of-execution message and terminates with
GOBACK. -
0000-CUSTFILE-OPEN— OpensCUSTFILE-FILEfor input. Checks the file status; if not'00'(success), it sets an error result, displays the I/O status viaZ-DISPLAY-IO-STATUS, and abends viaZ-ABEND-PROGRAM. -
1000-CUSTFILE-GET-NEXT— Reads the next record fromCUSTFILE-FILEintoCUSTOMER-RECORD(defined in copybookCVCUS01Y). It also performs a redundantDISPLAY CUSTOMER-RECORDinside 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 (setsEND-OF-FILEto'Y'); any other status triggers an error display and abend. -
9000-CUSTFILE-CLOSE— Closes the file, checking status the same way as open; any failure leads to error display and abend. -
Z-ABEND-PROGRAM— Displays'ABENDING PROGRAM', sets a hard-coded abend code (ABCODE = 999) and timing value (0), then calls the LE runtime serviceCEE3ABDto abnormally terminate the program. -
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 viaCEE3ABDwith hard-coded abend code999. There is no retry or recovery logic. - Hard-coded abend values:
ABCODEis always999andTIMINGis always0inZ-ABEND-PROGRAM, regardless of the actual error — this makes it impossible to distinguish open/read/close failures from the abend code alone (thoughZ-DISPLAY-IO-STATUSprints the underlying file status before abending). - Duplicate record display:
CUSTOMER-RECORDis displayed twice for each successfully read record — once inside1000-CUSTFILE-GET-NEXTand 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-STATUSincludes 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 copybookCVCUS01Y(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 |