Previous Topic: Run UnitsNext Topic: Record Locks


Sharing Run Units Between Programs

Multiple programs can share a single run unit by passing the IDMS communications block from one program to another program. Typically, the program that binds the run unit will allocate the IDMS communications block and then pass it to the other programs for their use.

COBOL Programmers

Even if the IDMS communications block is shared between programs, it is advisable to allow each program to generate its own list of records, sets, and area names so that if these change due to changes in the subschema, there is no need to recompile all programs sharing the run unit.

Example

The example below shows how to code the PROTOCOL section for two programs that are sharing a run unit. These examples are for a COBOL program.

Program-A
    IDENTIFICATION DIVISION
    PROGRAM-ID. MAINLINE.
    ENVIRONMENT DIVISION.
    IDMS-CONTROL SECTION.
    PROTOCOL. MODE IS BATCH-AUTOSTATUS DEBUG
            IDMS-RECORDS WITHIN WORKING-STORAGE SECTION.
    DATA DIVISION.
    SCHEMA SECTION.
    DB EMPSS01 WITHIN EMPSCHM VERSION 100.
    WORKING-STORAGE SECTION.

    PROCEDURE DIVISION.
    COPY IDMS SUBSCHEMA-BINDS
    READY USAGE-MODE IS UPDATE.
 * read some database records and do updates as needed. Then pass control
to a subprogram keeping the run unit open so that the subprogram can also
retrieve and update records as needed, and then return control to the
main program.
    CALL 'SUBPROG' USING SUBSCHEMA-CTRL.

Program-B
     IDENTIFCATION DIVISION
     PROGRAM-ID. SUBPROG.
     ENVIRONMENT DIVISION.
     IDMS-CONTROL SECTION.
     PROTOCOL. MODE IS BATCH-AUTOSTATUS DEBUG
             IDMS-RECORDS MANUAL.
     DATA DIVISION.
     SCHEMA SECTION.
     DB EMPSS01 WITHIN EMPSCHM VERSION 100.
     WORKING-STORAGE SECTION.
       COPY IDMS SUBSCHEMA-NAMES.
       COPY IDMS SUBSCHEMA-RECORDS.
     LINKAGE SECTION.
       COPY IDMS SUBSCHEMA-CTRL.

     PROCEDURE DIVISION USING SUBSCHEMA-STRL.
 * read some database records and do updates as needed. Then return
control to the main program keeping the run unit open.
         GOBACK.