Example 1: A single set of files with similar processing options
You use the same set of files each time you sign on.
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.
- 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 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.