In this example, the user signs on and most of the programs that
are used process the same set of files.
A control language (CL) program (PGMA) is used as the first program
(to set up the application, including overrides and opening the shared files).
PGMA then transfers control to PGMB, which displays the application menu.
Assume, in this example, that files A, B, and C are used, and files A and
B are to be shared. Files A and B were created with SHARE(*NO); therefore
the Override with Database File (OVRDBF) command should precede each of the
Open Database File (OPNDBF) commands to specify the SHARE(*YES) option. File
C was created with SHARE(*NO) and File C is not to be shared in this example.
PGMA: PGM /* PGMA - Initial program */
OVRDBF FILE(A) SHARE(*YES)
OVRDBF FILE(B) SHARE(*YES)
OPNDBF FILE(A) OPTION(*ALL) ....
OPNDBF FILE(B) OPTION(*INP) ...
TFRCTL PGMB
ENDPGM
PGMB: PGM /* PGMB - Menu program */
DCLF FILE(DISPLAY)
BEGIN: SNDRCVF RCDFMT(MENU)
IF (&RESPONSE *EQ '1') CALL PGM11
IF (&RESPONSE *EQ '2') CALL PGM12
.
.
IF (&RESPONSE *EQ '90') SIGNOFF
GOTO BEGIN
ENDPGM
The files opened in PGMA are either scoped to the job, or PGMA,
PGM11, and PGM12 run in the same activation group and the file opens are scoped
to that activation group.
In this example, assume that:
- PGM11 opens files A and B. Because these files were opened as shared by
the OPNDBF commands in PGMA, the open time is reduced. The close time is also
reduced when the shared open data path is closed. The OVRDBF commands remain
in effect even though control is transferred (with the Transfer Control (TFRCTL)
command in PGMA) to PGMB.
- PGM12 opens files A, B, and C. File A and B are already opened as shared
and the open time is reduced. Because file C is used only in this program,
the file is not opened as shared.
In this example, the Close File (CLOF) was not used because only
one set of files is required. When the operator signs off, the files are automatically
closed. It is assumed that PGMA (the initial program) is called only at the
start of the job. For more information about how to reclaim resources in the
Integrated Language Resources, see the ILE Concepts book.
Note: The display
file (DISPLAY) in PGMB can also be specified as a shared file, which can improve
the performance for opening the display file in any programs that use it later.
In Example 1, the OPNDBF commands are placed in a separate program
(PGMA) so the other processing programs in the job run as efficiently as possible.
That is, the important files used by the other programs in the job are opened
in PGMA. After the files are opened by PGMA, the main processing programs
(PGMB, PGM11, and PGM12) can share the files; therefore, their open and close
requests will process faster. In addition, by placing the open commands (OPNDBF)
in PGMA rather than in PGMB, the amount of main storage used for PGMB is reduced.
Any overrides and opens can be specified in the initial program
(PGMA); then, that program can be removed from the job (for example, by transferring
out of it). However, the open data paths that the program created when it
opened the files remain in existence and can be used by other programs in
the job.
Note: Overrides must be specified before the file is opened. Some
of the parameters on the OVRDBF command also exist on the OPNDBF command.
If conflicts arise, the OVRDBF value is used.