APIs by Example: Analyze Activation Groups

Article ID: 20000

For this installment of APIs by Example, I have written a utility based on two Open List APIs: "Open List of Activation Group Attributes" and "Open List of Activation Attributes." The utility is presented in the form of the Analyze Activation Groups (ANZACTGRP) command.

The Open List APIs topic has been discussed earlier in APIs by Example, in the following article of July 15, 2004: http://iseries.pentontech.com/t?ctl=196B:103C2

Activation groups are an aspect of the ILE (Integrated Language Environment) runtime and constitute a substructure of any job on the iSeries. The activation group contains the resources that are necessary to run a program, including static program variables, dynamic storage, open files (ODPs), SQL cursors, and many more.

You can control which activation groups your ILE programs run in by specifying the ACTGRP parameter on the Create Program (CRTPGM), Create Bound Program (CRTBNDxxx), or Create Service Program (CRTSRVPGM) command. The following screen shot shows where you specify the activation group on the CRTPGM command:

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
                        Create Program (CRTPGM)                           
Type choices, press Enter.                                                    
Program  . . . . . . . .               Name                         
  Library  . . . . . . .     *CURLIB   Name, *CURLIB                
Module . . . . . . . . .   *PGM        Name, generic*, *PGM, *ALL   
  Library  . . . . . . .               Name, *LIBL, *CURLIB...      
               + for more values                                              
Text 'description' . . .   *ENTMODTXT  
<...>
Activation group . . . .   QILE        Name, *NEW, *CALLER                                 

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

For OPM programs, the system creates two default activation groups for each job on the system and names them *DFTACTGRP. Running the command WRKJOB OPTION(*ACTGRP) produces the following panel:

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =                                                                              
                     Display Activation Group                            
                                                System:   S4004122  
Job:   QPADEV000D     User:   JAN            Number:   129706                  
----Activation Group-----                                                      
Number         Name           In Use Indicator                                 
0000000001     *DFTACTGRP        Yes                                           
0000000002     *DFTACTGRP        Yes                                           
0000000480     QILE              No                                            
0000000588     QLGLOCAL          No                                            

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =                                                                              

Activation groups 1 and 2 are the default activation groups that provide the scope of an OPM program's runtime resources. In the above example, the named activation groups QILE and QLGLOCAL are created as a result of calling an ILE program or service program that has been assigned to one of those activation groups.

The "In Use Indicator" column specifies whether the activation group is currently in use or not. An activation group that's not in use can be reclaimed using the Reclaim Activation Group (RCLACTGRP) command.

Use this command with great caution! Programs in other activation groups could still have a pointer to an activation of a service program in the activation group being reclaimed. This will cause a subsequent call to that program to generate an MCH3402 exception: "Tried to refer to all or part of an object that no longer exists."

Although you are able to find out what activation groups are currently active within a given job using the WRKJOB or DSPJOB OPTION(*ACTGRP) command, there is no facility available to display which programs are activated within each individual activation group.

That's where the Analyze Activation Groups (ANZACTGRP) command comes into play -- here's the command prompt:

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =                                                                              
                 Analyze Activation Groups (ANZACTGRP)              
Type choices, press Enter.                                              
Job name . . . . . . . . . .   *           Name, *                
  User . . . . . . . . . . .               Name                   
  Number . . . . . . . . . .               000000-999999          
Activation group name  . . .   *ALL        Name, *ALL, *DFTACTGRP

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =                                                                              

The command's help text offers more details about the command's individual parameters. The output from the command is directed to a spooled file and placed on the default output queue of the job that runs the command.

For each activation group that is included in the list, a number of activation group attributes are presented. These include, among others, the group name and number, a variety of storage information, and the name and type of the program that caused the activation group to be created.

Following each activation group is a list of all of the programs that are currently activated within the activation group. The following is an example of what part of the list might look like:

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =                                                                              
2/04/05  19:43:37        Job activation group attributes                        

Job name . . . :  QPADEV000D        User . . . . . :  JAN    

Group name    Number  Activations    Heaps  Static stg.  Heap stg.  
QTESAGRP         2531         44          1     4886528      94208     

Activation nbr.   Static stg.   Program     Library     Type                                                                     
      2532          262.144     QTEMODN     QSYS        *PGM                                                                     
      2533        5.242.880     QC2UTIL1    QSYS        *SRVPGM                                                                  
      2534          196.608     QC2LOCAL    QSYS        *SRVPGM                                                                  
      2535        3.145.728     QLEAWI      QSYS        *SRVPGM                                                                  

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =                                                                              

The activation group concept and activation group management is documented in great detail in the ILE Concepts manual (SC41-5606) that can be found at http://iseries.pentontech.com/t?ctl=1967:103C2 .

Specifically, chapter 3 (starting with page 29) and chapter 6 offer a lot of information on the subject of activation groups.

The Analyze Activation Groups utility demonstrates the following APIs:

Open List of Activation Group Attributes (QWVOLAGP) API: http://iseries.pentontech.com/t?ctl=1960:103C2

Open List of Activation Attributes (QWVOLACT) API: http://iseries.pentontech.com/t?ctl=195F:103C2

Get List Entries (QGYGTLE) API: http://iseries.pentontech.com/t?ctl=1962:103C2

Close List (QGYCLST) API: http://iseries.pentontech.com/t?ctl=1963:103C2

Send Program Message (QMHSNDPM) API: http://iseries.pentontech.com/t?ctl=1966:103C2

You can retrieve the source code for this utility from http://iseries.pentontech.com/t?ctl=1961:103C2 .

The above article was written by Carsten Flensburg. If you have any questions, you can contact Carsten at mailto:flensburg@novasol.dk .

ProVIP Sponsors

ProVIP Sponsors