beautypg.com

Compaq COBOL AAQ2G1FTK User Manual

Page 75

background image

Developing Compaq COBOL Programs

1.3 Developing Programs on OpenVMS Alpha

Example 1–2 Main Program and Subprograms

* CALLER.COB
IDENTIFICATION DIVISION.
PROGRAM-ID. CALLER.
******************************************************************
* This program calls a subprogram installed as a shareable image.*
******************************************************************
PROCEDURE DIVISION.
0.

CALL "SUBSHR1"

ON EXCEPTION

DISPLAY "First CALL failed. Program aborted."

END-CALL.
STOP RUN.

END PROGRAM CALLER.

* SUBSHR1.COB
IDENTIFICATION DIVISION.
PROGRAM-ID. SUBSHR1.

******************************************************************
* This program is linked as a shareable image. When it is called,*
* it calls another program installed as a shareable image.

*

******************************************************************
PROCEDURE DIVISION.
0.

DISPLAY "Call to SUBSHR1 successful. Calling SUBSHR2.".
CALL "SUBSHR2"

ON EXCEPTION

DISPLAY "Second call failed. Control returned to CALLER."

END-CALL.

END PROGRAM SUBSHR1.

* SUBSHR2.COB
IDENTIFICATION DIVISION.
PROGRAM-ID. SUBSHR2.
****************************************************************
* This program is linked as a shareable image and is called by *
* another shareable image.

*

****************************************************************
PROCEDURE DIVISION.
0.

DISPLAY "Call to SUBSHR2 successful!".

END PROGRAM SUBSHR2.

Example 1–3 shows a command procedure that compiles, links, and installs the
sample programs in Example 1–2.

Example 1–3 Command Procedure to Link a Program as a Shareable Image

$! Create the main program and subprograms to be installed as
$! shareable images. In this example CALLER.COB is the main program.
$! SUBSHR1.COB and SUBSHR2.COB are the subprograms to be installed
$! as shareable images.
$!

(continued on next page)

Developing Compaq COBOL Programs 1–45