CBACT02C
Source: cbl/CBACT02C.cbl
Type: Batch program
CBACT02C — Card Data File Reader
Purpose
This is a batch COBOL program that reads a card data file (VSAM KSDS) sequentially and prints each record to the job output. It appears to be a simple utility/extract program used to dump the contents of the card master file for review, auditing, or debugging purposes — it performs no calculations, updates, or business logic beyond reading and displaying records. It runs as part of job step READCARD.STEP05.
How it works
The main PROCEDURE DIVISION logic is a straightforward read loop:
0000-CARDFILE-OPEN— OpensCARDFILE-FILEfor input. If the open fails (file status ≠'00'), it displays an error, logs the I/O status, and abends the program.- Main loop — Repeatedly performs
1000-CARDFILE-GET-NEXTuntilEND-OF-FILEis set to'Y'. For each successfully read record, the program displays the record (DISPLAY CARD-RECORD) to standard output/job log. 1000-CARDFILE-GET-NEXT— Reads the next record fromCARDFILE-FILEintoCARD-RECORD(from copybookCVACT02Y). It translates the VSAM file status into an internalAPPL-RESULTcode:- Status
'00'→ success (APPL-RESULT = 0) - Status
'10'→ end-of-file (APPL-RESULT = 16, setsEND-OF-FILE = 'Y') - Any other status → treated as an error (
APPL-RESULT = 12), which triggers an error display, I/O status dump, and program abend. 9000-CARDFILE-CLOSE— Closes the file once the loop ends. Any non-zero close status also triggers an abend.- Error paths converge on two shared paragraphs:
9910-DISPLAY-IO-STATUS— Formats and displays the raw VSAM file status code (handles both numeric and non-numeric/'9' status values differently to render a readable 4-digit status).9999-ABEND-PROGRAM— Sets an abend code (ABCODE = 999) and calls the LE runtime serviceCEE3ABDto terminate the program abnormally.
Start/end of execution are marked with DISPLAY messages for job log tracing.
Inputs & outputs
| Name | Type | Description |
|---|---|---|
CARDFILE-FILE (DD CARDFILE) |
Input file (VSAM KSDS, indexed, sequential access) | The card data file being read. Record layout: FD-CARD-NUM (PIC X(16), also the record key) + FD-CARD-DATA (PIC X(134)). |
CVACT02Y (copybook) |
Working-storage layout | Defines CARD-RECORD, the structure into which each card record is moved for display. Not shown in provided source, but referenced via COPY CVACT02Y. |
| Job log / SYSOUT | Output | Every card record read is written via DISPLAY CARD-RECORD; status/error messages are also displayed here. |
CEE3ABD (external call) |
Runtime service | Language Environment routine used to abnormally terminate the program on unrecoverable errors. |
No CICS commands and no SQL/DB2 tables are used — this is a pure batch, file-only program.
Things to know
- No business logic: this program only reads and prints; it does not validate, transform, or write card data anywhere. Treat it as a diagnostic/reporting utility rather than part of the core processing chain.
- Hard-coded abend code:
ABCODEis always set to999regardless of the actual error, andTIMINGis always0. This means all abends look identical from the return code alone — the real cause must be found in the precedingDISPLAYmessages (error text + file status). - File status handling is coarse: any status other than
'00'(success) or'10'(EOF) is collapsed into a genericAPPL-RESULT = 12"error" — the specific VSAM status code is only visible via the9910-DISPLAY-IO-STATUSdisplay, not through distinct handling logic. - Abend on any error: open, read, or close failures all immediately call
9999-ABEND-PROGRAM, terminating the whole job — there is no retry or graceful degradation. - Odd arithmetic idioms:
9000-CARDFILE-CLOSEusesADD 8 TO ZERO GIVING APPL-RESULTandSUBTRACT APPL-RESULT FROM APPL-RESULTinstead of simpleMOVEstatements. Functionally equivalent, but stylistically unusual — worth noting for maintainers unfamiliar with COBOL idioms. - Commented-out debug line: inside
1000-CARDFILE-GET-NEXT, aDISPLAY CARD-RECORDline is commented out — the actual display of each record happens instead in the main loop inPROCEDURE DIVISION, so this comment is legacy/dead and could be misleading during maintenance. - File status field reuse:
IO-STATUS-04andTWO-BYTES-BINARY/TWO-BYTES-ALPHAare used to reformat the 2-byte VSAM status into a 4-digit display string; the logic branches based on whether the status is numeric or the first byte is'9', indicating some VSAM status codes (e.g., extended status codes starting with '9') require special decoding — this is a common but non-obvious COBOL/VSAM pattern. - No dynamic file name/parameters: the file is statically assigned to DD
CARDFILE; any change to the input file requires a JCL change, not a program change.
Files
| Logical file | DD name |
|---|---|
| CARDFILE-FILE | CARDFILE |
Copybooks
CVACT02Y
Calls
CEE3ABD
Executed by
READCARD.STEP05
Paragraph flow
flowchart TD
1000_CARDFILE_GET_NEXT["1000-CARDFILE-GET-NEXT"]
0000_CARDFILE_OPEN["0000-CARDFILE-OPEN"]
9000_CARDFILE_CLOSE["9000-CARDFILE-CLOSE"]
9999_ABEND_PROGRAM["9999-ABEND-PROGRAM"]
9910_DISPLAY_IO_STATUS["9910-DISPLAY-IO-STATUS"]
0000_CARDFILE_OPEN --> 9910_DISPLAY_IO_STATUS
0000_CARDFILE_OPEN --> 9999_ABEND_PROGRAM
1000_CARDFILE_GET_NEXT --> 9910_DISPLAY_IO_STATUS
1000_CARDFILE_GET_NEXT --> 9999_ABEND_PROGRAM
9000_CARDFILE_CLOSE --> 9910_DISPLAY_IO_STATUS
9000_CARDFILE_CLOSE --> 9999_ABEND_PROGRAM
Paragraphs
| Paragraph | Line | Performs |
|---|---|---|
| 1000-CARDFILE-GET-NEXT | 92 | 9910-DISPLAY-IO-STATUS, 9999-ABEND-PROGRAM |
| 0000-CARDFILE-OPEN | 118 | 9910-DISPLAY-IO-STATUS, 9999-ABEND-PROGRAM |
| 9000-CARDFILE-CLOSE | 136 | 9910-DISPLAY-IO-STATUS, 9999-ABEND-PROGRAM |
| 9999-ABEND-PROGRAM | 154 | |
| 9910-DISPLAY-IO-STATUS | 161 |