DBUNLDGS
Source: app-authorization-ims-db2-mq/cbl/DBUNLDGS.CBL
Type: Batch program
DBUNLDGS — Program Documentation
Purpose
DBUNLDGS is a batch IMS-to-GSAM unload utility. It reads every Pending Authorization Summary record (the IMS root segment PAUTSUM0) and its associated Pending Authorization Details child records (segment PAUTDTL1) from an IMS database, and copies them out unchanged into two GSAM sequential extract files. In business terms, it produces a full extract/backup of the pending-authorization database (summary + detail records) so the data can be reloaded, archived, or fed to a downstream process.
How it works
Processing is driven by MAIN-PARA, which follows a simple sequential-read/extract pattern:
-
1000-INITIALIZE— Captures the current date (ACCEPT ... FROM DATE/DAY) and prints startup banner messages. (Note: the original file-open logic and aSYSINparameter read forPRM-INFOare commented out/disabled — see "Things to know".) -
2000-FIND-NEXT-AUTH-SUMMARY(looped until end of root segments) — Issues an IMSGN(Get Next) call viaCBLTDLIagainstPAUTBPCBusing an unqualified SSA for segmentPAUTSUM0, retrieving the next Pending Authorization Summary root segment. - If the call succeeds (status = spaces), the summary record is copied to a working buffer, the account ID (
PA-ACCT-ID) is validated as numeric, and if valid:3100-INSERT-PARENT-SEG-GSAMis performed to write the summary segment to the GSAM output file.3000-FIND-NEXT-AUTH-DTLis performed repeatedly to pull all child detail segments for this parent, until no more children exist.
- If status =
GB(end of database), the root-segment loop flag is set and the program stops reading. -
Any other non-space, non-
GBstatus is treated as an error: it is displayed along with the IMS key feedback area, and the program aborts via9999-ABEND. -
3000-FIND-NEXT-AUTH-DTL— Issues an IMSGNP(Get Next within Parent) call viaCBLTDLIagainstPAUTBPCBfor segmentPAUTDTL1, retrieving detail child segments belonging to the current parent. - On success (status = spaces), the detail record is copied and
3200-INSERT-CHILD-SEG-GSAMwrites it to the GSAM output file. - On status
GE(no more segments under this parent), the child loop is ended. -
Any other status triggers a display of the error/key feedback area and an abend.
-
3100-INSERT-PARENT-SEG-GSAM— Issues an IMSISRTcall viaCBLTDLIagainst thePASFLPCB(GSAM PCB) to write the Pending Authorization Summary segment to the first GSAM output file. Any non-space status aborts the program. -
3200-INSERT-CHILD-SEG-GSAM— Issues an IMSISRTcall viaCBLTDLIagainst thePADFLPCB(GSAM PCB) to write the Pending Authorization Details segment to the second GSAM output file. Any non-space status aborts the program. -
4000-FILE-CLOSE— Displays a closing message. (The actualCLOSEstatements for the legacy sequential files are commented out — GSAM close is implicitly handled by IMS/PCB termination, not by explicit COBOL file I/O here.) -
9999-ABEND— Common error routine: displays an abend message, setsRETURN-CODEto 16, and terminates viaGOBACK.
Inputs & Outputs
| Resource | Type | Direction | Purpose |
|---|---|---|---|
PAUTBPCB |
IMS DB PCB (linkage, copybook PAUTBPCB) |
Input | Source IMS database access path used for GN/GNP calls against the Pending Authorization database (root segment PAUTSUM0, child segment PAUTDTL1). |
PASFLPCB |
IMS GSAM PCB (linkage, copybook PASFLPCB) |
Output | GSAM sequential extract file that receives the Pending Authorization Summary (parent) segments via ISRT. |
PADFLPCB |
IMS GSAM PCB (linkage, copybook PADFLPCB) |
Output | GSAM sequential extract file that receives the Pending Authorization Details (child) segments via ISRT. |
PENDING-AUTH-SUMMARY (copybook CIPAUSMY) |
IMS segment layout | Data structure | Layout of the root/summary segment retrieved and inserted. |
PENDING-AUTH-DETAILS (copybook CIPAUDTY) |
IMS segment layout | Data structure | Layout of the child/detail segment retrieved and inserted. |
IMSFUNCS copybook |
Constants | — | Supplies IMS call-function codes (FUNC-GN, FUNC-GNP, FUNC-ISRT, etc.) used in CBLTDLI calls. |
Legacy OPFILE1/OPFILE2 (commented out) |
Sequential files | N/A (unused) | Originally intended as flat-file outputs; superseded by the GSAM PCB approach — see quirks below. |
No relational/SQL tables or CICS commands are used by this program (batch IMS DL/I only).
Things to know
-
Dead/legacy code left in place: The
FILE-CONTROLSELECTstatements forOPFILE1/OPFILE2, theirOPEN,WRITE, andCLOSElogic, and file-status error handling are all commented out. The equivalent 01-level record layouts (OPFIL1-REC,OPFIL2-REC) still exist in Working-Storage and are populated (MOVE PENDING-AUTH-SUMMARY TO OPFIL1-REC, etc.) but never written to a sequential file — the data is written only through the GSAM PCBs (PASFLPCB/PADFLPCB) instead. This suggests the program was migrated from flat-file output to GSAM output, and the old code was left for reference. Anyone modifying this program should be careful not to assumeOPFILE1/OPFILE2are active. -
Parameter input disabled:
PRM-INFO(containingP-EXPIRY-DAYS,P-CHKP-FREQ,P-CHKP-DIS-FREQ,P-DEBUG-FLAG) is defined but theACCEPT PRM-INFO FROM SYSINstatement is commented out, so these fields are never populated. Related working-storage fields likeWS-EXPIRY-DAYS,WS-DAY-DIFF, checkpoint counters (WS-NO-CHKP,WK-CHKPT-ID) are declared but not used anywhere in the visible procedure logic — likely vestiges of checkpoint/restart or expiry-date functionality that was never completed or was removed. -
Numeric validation guard: Only summary records where
PA-ACCT-ID IS NUMERICare processed and have their children extracted; non-numeric account IDs are silently skipped (no detail read, no error, no log message). This is a potential data-quality blind spot — any summary segment with a corrupt/non-numeric account ID is silently dropped from the extract with no record of the skip. -
Error handling is abrupt: Any unexpected IMS status code from
GN,GNP, orISRTcalls (other than the expected space/GB/GEconditions) causes an immediate9999-ABEND, which setsRETURN-CODE = 16and callsGOBACK— there is no cleanup, checkpoint, or partial-completion handling. A failure partway through a large unload leaves the target GSAM files in a partial state with no resumption logic. -
Hard-coded segment names: The unqualified SSAs (
ROOT-UNQUAL-SSA='PAUTSUM0',CHILD-UNQUAL-SSA='PAUTDTL1') are hard-coded literals, meaning the program is tightly bound to these specific IMS segment names; any DBD/segment renaming requires a source code change and recompile. -
No CICS or SQL involved: This is a pure batch DL/I program (uses
CBLTDLIcalls only), consistent with the extracted facts showing no CICS commands and no SQL tables. -
Verbose debug output is fully commented out: Numerous
DISPLAYstatements showing PCB status, segment names, and levels after each IMS call are commented out throughout2000-FIND-NEXT-AUTH-SUMMARY,3000-FIND-NEXT-AUTH-DTL,3100-INSERT-PARENT-SEG-GSAM, and3200-INSERT-CHILD-SEG-GSAM. Only error-path displays remain active, which may make problem diagnosis harder in production without re-enabling this commented debug code. -
FAILED/dynamic calls: The parser lists a call toFAILEDin addition toCBLTDLI; this is not visible as an explicitCALL 'FAILED'in the shown source and may reflect an IMS status-check macro/copybook expansion (e.g., insideIMSFUNCS) rather than a directly callable subprogram — this should be verified against theIMSFUNCScopybook source, which was not provided.
Copybooks
CIPAUDTY, CIPAUSMY, IMSFUNCS, PADFLPCB, PASFLPCB, 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"]
3100_INSERT_PARENT_SEG_GSAM["3100-INSERT-PARENT-SEG-GSAM"]
3100_EXIT["3100-EXIT"]
3200_INSERT_CHILD_SEG_GSAM["3200-INSERT-CHILD-SEG-GSAM"]
3200_EXIT["3200-EXIT"]
4000_FILE_CLOSE["4000-FILE-CLOSE"]
4000_EXIT["4000-EXIT"]
9999_ABEND["9999-ABEND"]
9999_EXIT["9999-EXIT"]
2000_FIND_NEXT_AUTH_SUMMARY --> 3000_FIND_NEXT_AUTH_DTL
2000_FIND_NEXT_AUTH_SUMMARY --> 3100_INSERT_PARENT_SEG_GSAM
2000_FIND_NEXT_AUTH_SUMMARY --> 9999_ABEND
3000_FIND_NEXT_AUTH_DTL --> 3200_INSERT_CHILD_SEG_GSAM
3000_FIND_NEXT_AUTH_DTL --> 9999_ABEND
3100_INSERT_PARENT_SEG_GSAM --> 9999_ABEND
3200_INSERT_CHILD_SEG_GSAM --> 9999_ABEND
MAIN_PARA --> 1000_INITIALIZE
MAIN_PARA --> 2000_FIND_NEXT_AUTH_SUMMARY
MAIN_PARA --> 4000_FILE_CLOSE
Paragraphs
| Paragraph | Line | Performs |
|---|---|---|
| MAIN-PARA | 164 | 1000-INITIALIZE, 2000-FIND-NEXT-AUTH-SUMMARY, 4000-FILE-CLOSE |
| 1000-INITIALIZE | 182 | |
| 1000-EXIT | 212 | |
| 2000-FIND-NEXT-AUTH-SUMMARY | 216 | 3100-INSERT-PARENT-SEG-GSAM, 3000-FIND-NEXT-AUTH-DTL, 9999-ABEND |
| 2000-EXIT | 258 | |
| 3000-FIND-NEXT-AUTH-DTL | 263 | 3200-INSERT-CHILD-SEG-GSAM, 9999-ABEND |
| 3000-EXIT | 296 | |
| 3100-INSERT-PARENT-SEG-GSAM | 300 | 9999-ABEND |
| 3100-EXIT | 316 | |
| 3200-INSERT-CHILD-SEG-GSAM | 319 | 9999-ABEND |
| 3200-EXIT | 335 | |
| 4000-FILE-CLOSE | 338 | |
| 4000-EXIT | 354 | |
| 9999-ABEND | 357 | |
| 9999-EXIT | 365 |