CBPAUP0C
Source: app-authorization-ims-db2-mq/cbl/CBPAUP0C.cbl
Type: Batch program
CBPAUP0C — Delete Expired Pending Authorization Messages
Purpose
This is a batch COBOL/IMS program that cleans up expired "pending authorization" records from the CardDemo authorization database. It walks through all pending authorization summary records and their child detail records, identifies those that have aged past a configurable expiry threshold, and deletes them from the IMS database. Progress is checkpointed periodically so the job can be restarted without redoing all the work.
How it works
- MAIN-PARA drives the whole program:
- Calls 1000-INITIALIZE once to read parameters and set defaults.
- Calls 2000-FIND-NEXT-AUTH-SUMMARY to fetch the first root (summary) segment.
- Loops (
PERFORM UNTIL ERR-FLG-ON OR END-OF-AUTHDB) over all summary segments:- For each summary, calls 3000-FIND-NEXT-AUTH-DTL to get the first child (detail) segment, then loops over all details for that summary (
PERFORM UNTIL NO-MORE-AUTHS): - 4000-CHECK-IF-EXPIRED computes the age of the detail record and flags it for deletion if old enough.
- If flagged, 5000-DELETE-AUTH-DTL deletes the detail segment.
- 3000-FIND-NEXT-AUTH-DTL is called again to advance to the next detail (get-next-within-parent).
- After all details for a summary are processed, if the approved-auth counters are
<= 0, 6000-DELETE-AUTH-SUMMARY deletes the summary (root) segment. - If the number of summaries processed since the last checkpoint exceeds
P-CHKP-FREQ, 9000-TAKE-CHECKPOINT is called and the counter is reset. - 2000-FIND-NEXT-AUTH-SUMMARY fetches the next summary segment, and the outer loop repeats.
- For each summary, calls 3000-FIND-NEXT-AUTH-DTL to get the first child (detail) segment, then loops over all details for that summary (
- After the loop ends (no more summaries or an error flag was set), a final 9000-TAKE-CHECKPOINT is taken.
-
Summary statistics (summaries/details read and deleted) are displayed, then the program ends with
GOBACK. -
1000-INITIALIZE reads the current date (
ACCEPT ... FROM DATE/DAY), reads run parameters fromSYSINintoPRM-INFO, and applies defaults if parameters are missing or invalid: expiry days defaults to 5, checkpoint frequency defaults to 5, checkpoint-display frequency defaults to 10, and the debug flag defaults to'N'. -
2000-FIND-NEXT-AUTH-SUMMARY issues an IMS
GN(get-next) call against segmentPAUTSUM0using PCB #2. A blankDIBSTATmeans a record was found (counters incremented, current account ID saved);'GB'means end of database; any other status triggers 9999-ABEND. -
3000-FIND-NEXT-AUTH-DTL issues an IMS
GNP(get-next-within-parent) call against segmentPAUTDTL1. Blank status = record found;'GE'or'GB'= no more details for this parent; any other status aborts via 9999-ABEND. -
4000-CHECK-IF-EXPIRED computes
WS-AUTH-DATEfromPA-AUTH-DATE-9C(using a99999 - dateinversion) and the day difference from the current Julian date (CURRENT-YYDDD). If the difference is >= the expiry-days threshold, the record qualifies for deletion, and the summary's running approved/declined auth counts and amounts are decremented accordingly (based onPA-AUTH-RESP-CODE). -
5000-DELETE-AUTH-DTL and 6000-DELETE-AUTH-SUMMARY issue IMS
DLETcalls for the detail and summary segments respectively. Success (blankDIBSTAT) increments delete counters; failure aborts via 9999-ABEND. -
9000-TAKE-CHECKPOINT issues an IMS
CHKPcall with a rolling checkpoint ID (WK-CHKPT-ID). Success increments an internal checkpoint counter and periodically displays progress (based onP-CHKP-DIS-FREQ); failure aborts via 9999-ABEND. -
9999-ABEND displays an abend message, sets
RETURN-CODEto 16, and terminates the program (GOBACK) — no rollback logic beyond the last successful checkpoint.
Inputs & outputs
| Resource | Type | Usage |
|---|---|---|
PSBPAUTB (PCB #2, PAUT-PCB-NUM) |
IMS database (DL/I) | Root/segment access to pending authorization data. Root segment PAUTSUM0 and child segment PAUTDTL1 are read (GN/GNP), and deleted (DLET). |
CIPAUSMY (copybook) |
Layout | Defines PENDING-AUTH-SUMMARY (root segment PAUTSUM0) fields, e.g. PA-ACCT-ID, PA-APPROVED-AUTH-CNT, PA-APPROVED-AUTH-AMT, PA-DECLINED-AUTH-CNT, PA-DECLINED-AUTH-AMT. |
CIPAUDTY (copybook) |
Layout | Defines PENDING-AUTH-DETAILS (child segment PAUTDTL1) fields, e.g. PA-AUTH-DATE-9C, PA-AUTH-RESP-CODE, PA-APPROVED-AMT, PA-TRANSACTION-AMT. |
SYSIN |
Input parameter stream | Supplies PRM-INFO (expiry days, checkpoint frequency, checkpoint display frequency, debug flag) via ACCEPT. |
IO-PCB-MASK, PGM-PCB-MASK |
Linkage section (IMS-supplied PCBs) | Standard IMS batch linkage parameters; PGM-PCB-MASK corresponds to the PSB's I/O PCB, not explicitly used beyond linkage declaration in the given source. |
Console/SYSOUT (via DISPLAY) |
Output | Status messages, debug traces (when P-DEBUG-FLAG = 'Y'), error messages, and final run statistics (records read/deleted). |
RETURN-CODE |
Program exit status | Set to 16 on abend (9999-ABEND); otherwise defaults to 0 on normal completion. |
No relational/SQL tables are used (sql_tables is empty) — this program works exclusively against IMS hierarchical data via DL/I calls, and no separate sequential files (files list is empty) are declared in FILE-CONTROL.
Things to know
- No explicit PSB schedule call is visible in this source.
WS-IMS-VARIABLESdefinesPSB-NAME,PAUT-PCB-NUM, and anIMS-PSB-SCHD-FLG, but noEXEC DLI PCB/schedule statement appears in the given PROCEDURE DIVISION — scheduling is likely handled by the batch driver/JCL (PSBPSBPAUTB) rather than in-program. Confirm this externally if PSB scheduling logic is expected. - Hard-coded defaults: expiry days = 5, checkpoint frequency = 5, checkpoint-display frequency = 10, debug flag = 'N' — all applied only if
SYSINparameters are missing/invalid/zero. These are business-relevant thresholds hidden in code rather than externally documented. - Suspicious duplicate condition: in
MAIN-PARA, the summary-delete-eligibility check readsIF PA-APPROVED-AUTH-CNT <= 0 AND PA-APPROVED-AUTH-CNT <= 0— the same field is checked twice; this looks like a bug wherePA-DECLINED-AUTH-CNTwas probably intended for the second condition. As written, declined-count is never checked before deleting a summary. - Date logic is non-obvious:
WS-AUTH-DATEis derived via99999 - PA-AUTH-DATE-9C, implyingPA-AUTH-DATE-9Cis stored as an inverted Julian date (common IMS/DL/I technique to allow ascending key order for descending date sort). This transform must be preserved correctly if re-implemented. - Error handling is fail-fast and blunt: any unexpected
DIBSTATfrom IMS calls (GN, GNP, DLET, CHKP) immediately triggers 9999-ABEND, which setsRETURN-CODE = 16and stops the whole job — there's no partial-retry or granular recovery beyond the last successful checkpoint (CHKP). - Checkpointing relies on a rolling 4-digit counter (
WK-CHKPT-ID-CTR) appended to the literal'RMAD'; the counter itself is never shown being incremented in the given source, meaning every checkpoint may use the same ID (RMAD0000) unless incremented elsewhere not visible here — worth verifying, as reused checkpoint IDs can be problematic for IMS restart processing. - Debug output is controlled by
P-DEBUG-FLAG(DEBUG-ON) and adds extraDISPLAYstatements at several points (record reads and deletes) — useful for troubleshooting but should be disabled in production runs to avoid excessive log volume. - No SQL/DB2 access and no CICS commands are used; this is a pure batch/IMS program, which is important context for anyone assuming this uses relational tables based on similarly named copybooks elsewhere in the CardDemo application.
Copybooks
CIPAUDTY, CIPAUSMY
Paragraph flow
flowchart TD
MAIN_PARA["MAIN-PARA"]
1000_INITIALIZE["1000-INITIALIZE"]
1000_EXIT["1000-EXIT"]
2000_FIND_NEXT_AUTH_SUMMARY["2000-FIND-NEXT-AUTH-SUMMARY"]
2000_EXIT["2000-EXIT"]
3000_FIND_NEXT_AUTH_DTL["3000-FIND-NEXT-AUTH-DTL"]
3000_EXIT["3000-EXIT"]
4000_CHECK_IF_EXPIRED["4000-CHECK-IF-EXPIRED"]
4000_EXIT["4000-EXIT"]
5000_DELETE_AUTH_DTL["5000-DELETE-AUTH-DTL"]
5000_EXIT["5000-EXIT"]
6000_DELETE_AUTH_SUMMARY["6000-DELETE-AUTH-SUMMARY"]
6000_EXIT["6000-EXIT"]
9000_TAKE_CHECKPOINT["9000-TAKE-CHECKPOINT"]
9000_EXIT["9000-EXIT"]
9999_ABEND["9999-ABEND"]
9999_EXIT["9999-EXIT"]
2000_FIND_NEXT_AUTH_SUMMARY --> 9999_ABEND
3000_FIND_NEXT_AUTH_DTL --> 9999_ABEND
5000_DELETE_AUTH_DTL --> 9999_ABEND
6000_DELETE_AUTH_SUMMARY --> 9999_ABEND
9000_TAKE_CHECKPOINT --> 9999_ABEND
MAIN_PARA --> 1000_INITIALIZE
MAIN_PARA --> 2000_FIND_NEXT_AUTH_SUMMARY
MAIN_PARA --> 3000_FIND_NEXT_AUTH_DTL
MAIN_PARA --> 4000_CHECK_IF_EXPIRED
MAIN_PARA --> 5000_DELETE_AUTH_DTL
MAIN_PARA --> 6000_DELETE_AUTH_SUMMARY
MAIN_PARA --> 9000_TAKE_CHECKPOINT
Paragraphs
| Paragraph | Line | Performs |
|---|---|---|
| MAIN-PARA | 136 | 1000-INITIALIZE, 2000-FIND-NEXT-AUTH-SUMMARY, 3000-FIND-NEXT-AUTH-DTL, 4000-CHECK-IF-EXPIRED, 5000-DELETE-AUTH-DTL, 3000-FIND-NEXT-AUTH-DTL |
| 1000-INITIALIZE | 183 | |
| 1000-EXIT | 212 | |
| 2000-FIND-NEXT-AUTH-SUMMARY | 216 | 9999-ABEND |
| 2000-EXIT | 243 | |
| 3000-FIND-NEXT-AUTH-DTL | 248 | 9999-ABEND |
| 3000-EXIT | 273 | |
| 4000-CHECK-IF-EXPIRED | 277 | |
| 4000-EXIT | 299 | |
| 5000-DELETE-AUTH-DTL | 303 | 9999-ABEND |
| 5000-EXIT | 324 | |
| 6000-DELETE-AUTH-SUMMARY | 328 | 9999-ABEND |
| 6000-EXIT | 348 | |
| 9000-TAKE-CHECKPOINT | 352 | 9999-ABEND |
| 9000-EXIT | 373 | |
| 9999-ABEND | 377 | |
| 9999-EXIT | 385 |