Linking code by using a COBOL dynamic link

Use a dynamic link to link the generated COBOL program independently from the calling program.

About this task

Using a dynamic link, you can link the generated COBOL program independently from the calling program. This way of linking is similar to using a CICS® EXEC CICS LINK, except that with a dynamic link, both the generated COBOL program and the COBOL calling program must reside in the same CICS system.

Tip: With an EXEC CICS LINK, the programs can be in different CICS systems.

Procedure

  1. Declare the generated COBOL program as a constant in the WORKING-STORAGE section of the calling program. For example:

    01 GENERATED-PROG PIC X(8) VALUE 'MINICBL'

    Where MINICBL is the name of the generated COBOL program file.

  2. Add a CALL statement to the PROCEDURE DIVISION of the calling program that uses this constant. For example:

    CALL GENERATED-PROG USING BORROWER LOAN

    You reference each Top Level data item with a USING clause.

  3. To link the COBOL program dynamically, select one of the following compile options:
    • For a batch program, specify DYNAM=YES.

    • For a CICS program, specify DYNAM=NO.

  4. To link the COBOL code into a CICS program, specify CICS=NO.
    Note: If you specify CICS=YES, CICS expects a COMMAREA to be passed to the COBOL-generated program. The generated COBOL program does not include a dummy COMMAREA, so specifying CICS=YES can result in 0C4 ABENDs occurring.

Results

When you run the calling program, the rules are executed.