Effect of exits on overrides: scenario

Exits (ENDPGM, RETURN, or abnormal exits) from a call operation delete overrides that are scoped to that call level. However, they do not delete overrides that are issued in that call level that are scoped to the activation group level or the job level.

For example, a RETURN command deletes all overrides scoped to that call level. Thus, overrides that are scoped to the call level in called programs that end with a RETURN or ENDPGM command do not apply to the calling program. This is not true for programs that use the Transfer Control (TFRCTL) command.

In Figure 1, the RETURN command deletes the first override in program B, and FILE X is opened in program A. However, the RETURN command does not delete the second override because it is scoped to the job level. FILE B is opened in program A when program A processes the Open FILE A command.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
Figure 1. Example of effect of exits on overrides. An example that outlines the effects of exits on overrides.

              Program A
                 .
                 .
                 .

              CALL PGM(B)

                  Program B
Override 1    OVRDBF FILE(X) FILE(Y)
Override 2    OVRDBF FILE(A) TOFILE(B) +
                       OVRSCOPE(*JOB)
                     .
                     .
                     .

                 RETURN

            OPEN FILE X
                .
                .
                .
            OPEN FILE A