Example 1: A single set of files with similar processing options

 

You use the same set of files each time you sign on. 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.

By using the code examples, you agree to the terms of the Code license and disclaimer information.

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:

In this example, the Close File (CLOF) command is 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.

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.

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.

 

Parent topic:

Close considerations for files shared in a job or an activation group

 

Related concepts

ILE Concepts PDF