Sign in

docs ILE Concepts

Mixed Languages—Scenario

Mixed Languages—Scenario

Mixed Languages—Scenario

Without activation groups, which are introduced by ILE, interactions among OPM languages are difficult to predict. ILE activation groups can solve that difficulty.

For example, consider the problems caused by mixing COBOL with other languages. The COBOL language standard includes a concept known as a run unit. A run unit groups programs together so that under certain circumstances they behave as a single entity. This can be a very useful feature.

Assume that three ILE COBOL programs (PRGA, PRGB, and PRGC) form a small application in which PRGA calls PRGB, which in turn calls PRGC (see Figure 1). Under the rules of ILE COBOL, these three programs are in the same run unit. As a result, if any of them ends, all three programs should be ended and control should return to the caller of PRGA.

Figure 1. Three ILE COBOL Programs in a Run Unit

Three COBOL programs in a run unit

Suppose that we now introduce an RPG program (RPG1) into the application and that RPG1 is also called by the COBOL program PRGB (see Figure 2). An RPG program expects that its variables, files, and other resources remain intact until the program returns with the last-record (LR) indicator on.

Figure 2. Three ILE COBOL Programs and One ILE RPG Program in a Run Unit

Three programs and one RPG program in a run unit

However, the fact that program RPG1 is written in RPG does not guarantee that all RPG semantics apply when RPG1 is run as part of the COBOL run unit. If the run unit ends, RPG1 disappears regardless of its LR indicator setting. In many cases, this situation may be exactly what you want. However, if RPG1 is a utility program, perhaps controlling the issue of invoice numbers, this situation is unacceptable.

We can prevent this situation by running the RPG program in a separate activation group from the COBOL run unit (see Figure 3). An ILE COBOL run unit itself is an activation group.

Figure 3. ILE RPG Program in a Separate Activation Group

RPG program in a separate activation group

For information about the differences between an OPM run unit and an ILE run unit, see the ILE COBOL Programmer’s GuideLink to PDF.