Program storage

Two steps are needed to run a program: program activation and program invocation.

Program activation is the process of allocating and initializing static storage for the program. Program invocation is the process of allocating and initializing automatic storage.

Program activation and static storage

Program activation can be done explicitly through the Activate Program (ACTPG) instruction or implicitly by using a call external (CALLX) instruction when the called program has not been previously activated. Program activation typically occurs only once within a job or process. Program activation is not reset by an RTX instruction within the called program (the program is still considered to be in an activated state). This means that all static storage on subsequent calls (CALLXs) to the program are found in a last-used state, not in a reinitialized state. If a programmer wants to reinitialize the static storage associated with a program activation, this can be accomplished through the deactivate program (DEACTPG) instruction so that the next call (CALLX or ACTPG) causes a new activation of the program.

Program invocation and automatic storage

Program invocation, on the other hand, occurs every time a program is called with a CALLX instruction. Automatic storage is reinitialized if a discrete INIT value was specified on the declare (DCL) statement. (If the INIT was allowed to be the default, then whether or not initialization occurs for the field is determined by an option of the QPRCRTPG API when the program was created.) If you have not already done so, review all of the option template values available on the QPRCRTPG API before developing your MI applications.

Related tasks
Enhanced version of the MICRTPG program