Skip to content

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:

  1. 1000-INITIALIZE — Captures the current date (ACCEPT ... FROM DATE/DAY) and prints startup banner messages. (Note: the original file-open logic and a SYSIN parameter read for PRM-INFO are commented out/disabled — see "Things to know".)

  2. 2000-FIND-NEXT-AUTH-SUMMARY (looped until end of root segments) — Issues an IMS GN (Get Next) call via CBLTDLI against PAUTBPCB using an unqualified SSA for segment PAUTSUM0, retrieving the next Pending Authorization Summary root segment.

  3. 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-GSAM is performed to write the summary segment to the GSAM output file.
    • 3000-FIND-NEXT-AUTH-DTL is performed repeatedly to pull all child detail segments for this parent, until no more children exist.
  4. If status = GB (end of database), the root-segment loop flag is set and the program stops reading.
  5. Any other non-space, non-GB status is treated as an error: it is displayed along with the IMS key feedback area, and the program aborts via 9999-ABEND.

  6. 3000-FIND-NEXT-AUTH-DTL — Issues an IMS GNP (Get Next within Parent) call via CBLTDLI against PAUTBPCB for segment PAUTDTL1, retrieving detail child segments belonging to the current parent.

  7. On success (status = spaces), the detail record is copied and 3200-INSERT-CHILD-SEG-GSAM writes it to the GSAM output file.
  8. On status GE (no more segments under this parent), the child loop is ended.
  9. Any other status triggers a display of the error/key feedback area and an abend.

  10. 3100-INSERT-PARENT-SEG-GSAM — Issues an IMS ISRT call via CBLTDLI against the PASFLPCB (GSAM PCB) to write the Pending Authorization Summary segment to the first GSAM output file. Any non-space status aborts the program.

  11. 3200-INSERT-CHILD-SEG-GSAM — Issues an IMS ISRT call via CBLTDLI against the PADFLPCB (GSAM PCB) to write the Pending Authorization Details segment to the second GSAM output file. Any non-space status aborts the program.

  12. 4000-FILE-CLOSE — Displays a closing message. (The actual CLOSE statements 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.)

  13. 9999-ABEND — Common error routine: displays an abend message, sets RETURN-CODE to 16, and terminates via GOBACK.

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-CONTROL SELECT statements for OPFILE1/OPFILE2, their OPEN, WRITE, and CLOSE logic, 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 assume OPFILE1/OPFILE2 are active.

  • Parameter input disabled: PRM-INFO (containing P-EXPIRY-DAYS, P-CHKP-FREQ, P-CHKP-DIS-FREQ, P-DEBUG-FLAG) is defined but the ACCEPT PRM-INFO FROM SYSIN statement is commented out, so these fields are never populated. Related working-storage fields like WS-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 NUMERIC are 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, or ISRT calls (other than the expected space/GB/GE conditions) causes an immediate 9999-ABEND, which sets RETURN-CODE = 16 and calls GOBACK — 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 CBLTDLI calls only), consistent with the extracted facts showing no CICS commands and no SQL tables.

  • Verbose debug output is fully commented out: Numerous DISPLAY statements showing PCB status, segment names, and levels after each IMS call are commented out throughout 2000-FIND-NEXT-AUTH-SUMMARY, 3000-FIND-NEXT-AUTH-DTL, 3100-INSERT-PARENT-SEG-GSAM, and 3200-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 to FAILED in addition to CBLTDLI; this is not visible as an explicit CALL 'FAILED' in the shown source and may reflect an IMS status-check macro/copybook expansion (e.g., inside IMSFUNCS) rather than a directly callable subprogram — this should be verified against the IMSFUNCS copybook 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