IBM i Activation Groups – Part 1

Once upon a time an RPG programmer discover some files remained opened after the program that used them had ended. The very first thing that came to his mind was that *inlr=*on wasn’t present in the code as the program had ended without issues. So he opened the member in LPEX editor, went directly to the part where the main code ended and BINGO, just a return operation code. But experience is a rank and he wanted to be sure that this was a mistake and not something done on purpose so he went to the beginning of the code and started a complete trace and then he saw it, actgrp(*caller)…

Yes, it could be the beginning of a “police code” genre novel whose plot was the investigation carried out by a programmer looking for bugs in his code but no, this is the real life. And it is related to Activation Groups and the fact that if you have to call a program several times it’s better to end this program only with return operation code to save time the next time the program is called as the program only opens the files the first time is called and not all times among other things. In this article you’ll find information about activation groups and how to manage them. There will be three more articles with examples, program codes and screen captures showing them in action so stay tuned.

What is an activation group? Well the short definition could be a subdivision of the job where programs can run in isolation from other programs of the same job. One job can have several activation groups all of them with the resources needed to run a program, an ILE program, that’s it RPGLE, CLLE and so on.

What resources are inside the activation group? Well as you can see in IBM Website here some of the resources are:

  • Opened files and data paths
  • Commitment definitions
  • Local and remote SQL cursors
  • Query management instances

among others.

A first graphical approach could be this picture. The picture will be changed as other terms are explained later in this post. Actually you can see three different activation groups in the same job. Each activation group has three different programs running. PGM1, PGM2 and PGM3 share resources as they are in the same activation group and the same is true for the rest of the programs.

Fig. 1 Activation group

You usually don’t have to worry about activation groups since the default values of the build commands are sufficient. CRTPGM, CRTSRVPGM and CRTBNDRPG have a parameter called ACTGRP that can be used to specify in which activation group you want the program run

You have four options to choose:

  1. Default Activation Group (DFTACTGRP)

This is the default option when you compile a program with CRTBNDRPG. In this special case the program will run in the default activation group and it will be treated like any other OPM (Original Programming Model (RPG/400)) program. If you want to change this behavior you must change the value of the parameter DFTACTGRP to *NO or use the control specification keyword DFTACTGRP(*NO). Once you change this value you are able to specify the activation group for the program in the ACTGRP parameter or in the control specification keyword ACTGRP.

  1. User-defined name

You can name the activation group with a name of your convenience. The first time the program is run the system will create the activation group and the program will be run inside it. Any other program with the same name in the ACTGRP parameter will be run in the same activation group. The activation group will be destroyed once the job ends or if t he user runs the command RCLACTGRP (Reclaim Activation Group) and there is no program running inside it.

You can use this option with these commands:

CRTBNDRPG PGM(LIBRARY/PROGRAM) DFTACTGRP(*NO) ACTGRP(ACTGRP_NAME)

CRTPGM PGM(LIBRARY/PROGRAM) ACTGRP(ACTGRP_NAME)

CRTSRVPGM SRVPGM(LIBRARY/SERVICE_PROGRAM) ACTGRP(ACTGRP_NAME)

There is one more thing to consider with default values and this approach. If you don’t specify and activation group name default values in the command will be used to determine which activation group to use and if you haven’t changed the command the activation group name will be QILE if single level storage model is used in the creation of the program or QILETS if the model is teraspace.

  1. *NEW

With this option the system will create a new activation group every time the program is run. One of the advantages of using this approach is that the system will destroy the activation group once no program is running inside it. This option cannot be used with CRTSRVPGM command.

  1. *CALLER

The last but not the least important option with activation groups. If a program or service program is compiled with this option it will run in the same activation group as the caller program. This is the default option for CRTSRVPGM command.

Now it’s time to complete previous picture, Fig. 1, with the options just explained.

This table shows control keywords DftActGrp and ActGrp of each program plus which program is a calling program and which program is a called program.

Finally our job is configure as Fig 2 shows.

Leave a Reply

Your email address will not be published. Required fields are marked *