PAUDBUNL
Source: app-authorization-ims-db2-mq/cbl/PAUDBUNL.CBL
Type: Batch program
Purpose
PAUDBUNL ("IMSUNLOD") is a batch unload utility that extracts pending-authorization data from an IMS database and writes it out to two flat sequential files. It walks the IMS database hierarchically — reading each root Pending Authorization Summary segment and, for each one, all of its child Pending Authorization Detail segments — producing a full extract of the authorization data for downstream use (e.g., migration, reporting, or conversion to another data store). It is a straight read-and-unload program; it does not update or delete anything in the IMS database itself.
How it works
-
MAIN-PARA is the entry point (ENTRY 'DLITCBL' USING PAUTBPCB), consistent with a DL/I batch program invoked with an IMS PCB mask. It performs three steps in sequence:
-
1000-INITIALIZE — one-time setup.
-
2000-FIND-NEXT-AUTH-SUMMARY, repeated in a loop until WS-END-OF-ROOT-SEG = 'Y' — the main extraction loop over root segments.
-
4000-FILE-CLOSE — closes output files, then the program ends with GOBACK.
-
1000-INITIALIZE: Captures the current date/day (ACCEPT ... FROM DATE/DAY), displays a startup banner, then opens both output files (OPFILE1, OPFILE2). If either OPEN fails (file status not spaces or '00'), it displays an error and calls 9999-ABEND, which sets RETURN-CODE = 16 and terminates via GOBACK. Note: there is a commented-out ACCEPT PRM-INFO FROM SYSIN, meaning the parameter record (expiry days, checkpoint frequency, debug flag) defined in PRM-INFO is not actually being read — those working-storage fields are effectively unused/dead in the current code.
-
2000-FIND-NEXT-AUTH-SUMMARY (root segment retrieval):
-
Issues an IMS CALL 'CBLTDLI' USING FUNC-GN, PAUTBPCB, PENDING-AUTH-SUMMARY, ROOT-UNQUAL-SSA — a "Get Next" against the root segment type PAUTSUM0.
-
If the PCB status is spaces (success): counts the read, moves the segment to OPFIL1-REC, initializes the key/detail fields for file 2, and moves PA-ACCT-ID into ROOT-SEG-KEY. Only if PA-ACCT-ID is numeric does it write the record to OPFILE1 and then loop through 3000-FIND-NEXT-AUTH-DTL to pull all child detail segments for that root, until WS-END-OF-CHILD-SEG = 'Y'.
-
If the PCB status is 'GB' (IMS end-of-database), sets END-OF-AUTHDB/WS-END-OF-ROOT-SEG = 'Y', ending the main loop.
-
Any other non-space, non-'GB' status is treated as an unexpected IMS error: it displays the status and the key feedback area (PAUT-KEYFB), then calls 9999-ABEND.
-
3000-FIND-NEXT-AUTH-DTL (child segment retrieval):
-
Issues CALL 'CBLTDLI' USING FUNC-GNP, PAUTBPCB, PENDING-AUTH-DETAILS, CHILD-UNQUAL-SSA — a "Get Next within Parent" against child segment type PAUTDTL1.
-
On success (status = spaces): counts the read and writes the detail segment to OPFIL2-REC (paired with the previously-set ROOT-SEG-KEY).
-
On status 'GE' (segment not found / no more children under this parent): sets WS-END-OF-CHILD-SEG = 'Y' and displays a diagnostic message, ending the inner loop for this parent.
-
Any other status triggers a display of the error and key feedback area, then 9999-ABEND.
-
Regardless of outcome, PAUT-PCB-STATUS is re-initialized at the end of the paragraph before returning.
-
4000-FILE-CLOSE: Closes both output files, checking/reporting (but not abending on) close errors.
-
9999-ABEND: Common error exit — displays a termination message, sets RETURN-CODE = 16, and does GOBACK (does not use CICS ABEND; this is a batch/DL-I program, no CICS commands are present).
Inputs & outputs
Things to know
-
No SQL/DB2 or CICS usage — this is a pure batch DL/I (IMS) program; the parser found no SQL tables or CICS commands, consistent with the source.
-
Parameter input is disabled: the ACCEPT PRM-INFO FROM SYSIN line is commented out, so P-EXPIRY-DAYS, P-CHKP-FREQ, P-CHKP-DIS-FREQ, and P-DEBUG-FLAG are never populated from input — related working-storage fields (WS-EXPIRY-DAYS, WS-DAY-DIFF, checkpoint counters, WS-NO-CHKP) appear declared but not actively driven by parameters in this code path. Any checkpoint/restart logic implied by field names (WK-CHKPT-ID, WS-NO-CHKP) is not implemented in the visible PROCEDURE DIVISION — there is no CHKP/checkpoint call present.
-
Silent record-skipping: root summary segments are only written to OPFILE1 (and their children processed at all) if PA-ACCT-ID IS NUMERIC. Non-numeric account IDs are silently skipped — no error, count, or log entry — which could cause data loss without visibility if the source contains bad/blank account IDs.
-
Inconsistent error handling severity: 9999-ABEND is called (hard stop, return code 16) for OPEN failures and unexpected IMS statuses on both GN and GNP calls, but CLOSE failures in 4000-FILE-CLOSE are only displayed, not abended — the program will still return successfully (return code 0) even if file close fails.
-
Hard-coded values: segment names PAUTSUM0 and PAUTDTL1 are hard-coded into the unqualified SSAs; the program name IMSUNLOD is hard-coded in WS-PGMNAME and messages; abend return code is hard-coded to 16.
-
Heavy use of commented-out debug DISPLAY statements throughout paragraphs 2000 and 3000 — these appear to be leftover diagnostic code (segment level, PCB status, segment name dumps) disabled but not removed, suggesting the program was debugged in place and the instrumentation was never cleaned up or made conditional on P-DEBUG-FLAG (which itself is never set, since SYSIN read is disabled).
-
Status-check pattern relies on exact literal matching ('GB', 'GE', spaces) rather than the 88-level condition names already defined for these values (e.g., END-OF-DB, SEGMENT-NOT-FOUND) — the 88-levels exist in WS-IMS-VARIABLES/status field definitions but the procedure code re-tests PAUT-PCB-STATUS directly with literals, which is a minor maintainability inconsistency (two parallel status representations).
-
No executed_by_job_steps were identified by the parser, so the JCL step(s) that invoke this program (and thus the actual DD-to-dataset mappings for OUTFIL1/OUTFIL2) are not available from the extracted facts — this documentation cannot confirm downstream consumers of the two output files.
Files
| Logical file | DD name |
|---|---|
| OPFILE1 | OUTFIL1 |
| OPFILE2 | OUTFIL2 |
Copybooks
CIPAUDTY, CIPAUSMY, IMSFUNCS, PAUTBPCB
Calls
CBLTDLI, FAILED
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_FILE_CLOSE["4000-FILE-CLOSE"]
4000_EXIT["4000-EXIT"]
9999_ABEND["9999-ABEND"]
9999_EXIT["9999-EXIT"]
1000_INITIALIZE --> 9999_ABEND
2000_FIND_NEXT_AUTH_SUMMARY --> 3000_FIND_NEXT_AUTH_DTL
2000_FIND_NEXT_AUTH_SUMMARY --> 9999_ABEND
3000_FIND_NEXT_AUTH_DTL --> 9999_ABEND
MAIN_PARA --> 1000_INITIALIZE
MAIN_PARA --> 2000_FIND_NEXT_AUTH_SUMMARY
MAIN_PARA --> 4000_FILE_CLOSE
Paragraphs
| Paragraph | Line | Performs |
|---|---|---|
| MAIN-PARA | 157 | 1000-INITIALIZE, 2000-FIND-NEXT-AUTH-SUMMARY, 4000-FILE-CLOSE |
| 1000-INITIALIZE | 173 | 9999-ABEND, 9999-ABEND |
| 1000-EXIT | 203 | |
| 2000-FIND-NEXT-AUTH-SUMMARY | 207 | 3000-FIND-NEXT-AUTH-DTL, 9999-ABEND |
| 2000-EXIT | 248 | |
| 3000-FIND-NEXT-AUTH-DTL | 253 | 9999-ABEND |
| 3000-EXIT | 285 | |
| 4000-FILE-CLOSE | 289 | |
| 4000-EXIT | 305 | |
| 9999-ABEND | 308 | |
| 9999-EXIT | 316 |