02
Sat, Nov
2 New Articles

An Introduction to ILE Activation Groups

RPG
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

An ILE activation group is a substructure of a job. It is used to allocate and handle resources used by the programs running within the activation group. Activation groups are a vital component of ILE programming. In this article, we'll explore what activation groups are and how they affect the way your ILE programs run.

Program Activation

To understand the activation group concept, you have to first understand what ILE program activation is. Any ILE program or service program must be activated before the program is run. Activation initializes resources used by the program, including static variables, open files, SQL cursors, and open files. The activation process also handles binding of programs to associated service programs. The process of activating a program needs to occur only once within a given activation group. When a program is called, if it is not activated, program activation will occur. If, on the other hand, that program has already been activated, the existing activation is used.

When a program is activated, any static variables are initialized. Once a program has been activated, these variables remain available for access within the given activation group. It's important to remember that each job running a program has its own copy of each of these static variables. This means that if two users execute the same program, the static variables within each will be unique.

Activation Group Options

When determining what activation group a program will belong to, you have several options. The default activation group is automatically created when any job starts and destroyed when that job ends. While you can create ILE programs using the default activation group, you really lose much of the functionality that you use ILE for. For example, an ILE RPG program compiled to use the default activation group cannot contain any subprocedures.

The default activation group is used by all non-ILE (OPM) programs. When compiling an ILE RPG program, this option is specified on the DFTACTGRP parameter. Valid values are *YES to use the default activation group and *NO to define the activation group to be used. When *NO is specified, additional parameters for the activation group and binding directory to be used are displayed. You have several options when specifying the activation group: You can specify a named activation group that you've defined for the program, you can specify the special value *NEW to create a new activation group, or you can use *CALLER to identify that the program being compiled should always run in whatever activation group the program calling it is running in. With this last option, it is possible to have a true ILE application exist in the default activation group. The default value for this parameter is the QILE named activation group. Each of these has its own merits and purpose. Here's a breakdown of the life cycle of each type of activation group.

  • Named Activation Group--When a program with a named activation group is called, if the activation group does not exist, it is created. It remains in existence until any and all programs using that activation group are no longer active.
  • *NEW Activation Group--A program that was compiled with an activation group of *NEW creates a new activation group each time the program is called. This newly created activation group exists until the program that created it is no longer active.
  • *CALLER Activation Group--When *CALLER is specified, the activation group is already in existence when the program is called and will continue to exist until the activation group is deleted based on one of the two scenarios described above.

It's important to mention that the *NEW option is not available when creating a service program using the CRTSRVPGM command. The other two options, however, are both valid on that command. This is because the general idea behind a service program is that it will be used by many other programs. Creating a new activation group each time the service program is accessed wouldn't make much sense.

It's also important to note that a program within a given activation group can remain active even after the program has ceased execution. This can be accomplished in RPG, for example, by executing a RETURN statement without first turning on *INLR. In this circumstance, the activation group containing the program will remain in existence until the job under which the activation group has been created ends.

Activation Group Resources

As I mentioned, static variables keep their values as long as an activation group exists. In addition, open files remain open in their current state until their activation group is deleted. Static (or global) variables are either those defined within the main procedure of a program or those defined in subprocedures with the STATIC keyword. As you've already learned, these variables hold their value on concurrent calls to the same program. The source shown in Figure 1 is a simple ILE RPG program that can be used to illustrate static variables.

      *------------------------------------------------------------   
      *                                                             
      * Program: AGR001RG                         
      *                                           
      * Description: Sample of Global Variables          
      *                                                 
      * Compile Command: CRTBNDRPG PGM(xxx/AGR001RG)                
      *                            SRCFILE(xxx/QRPGLESRC)           
      *                            SRCMBR(AGR001RG)              
      *                            DFTACTGRP(*NO)      
      *                            ACTGRP(TEST)                     
      *                                                            
      *------------------------------------------------------------
     DAGR001RG         PR                                          
     D Action                         1                          
     DAGR001RG         PI                                    
     D Action                         1                              
     D Variable1       S              5  0                           
     C/FREE                                                        
      Select;                                  
        When Action = 'A';                                          
          Variable1 = Variable1 + 1;                
        When Action = 'S';            
          Variable1 = Variable1 - 1;                  
        When Action = 'X';                      
          *INLR = *ON;                            
          Return;                                    
      EndSl;                                    
      Dsply Variable1;                                         
      Return;                                               
     /END-FREE                               

Figure 1: This program helps illustrate the use of global variables.

You'll notice that the compile command shown creates a named activation group called TEST. When this program is called, if the activation group TEST doesn't exist, it will be created. Since this program contains only a single procedure, all of this program's variables are global.

The ACTION parameter defines the action to be performed by the program. A value of 'A' tells the program to add 1 to Variable1. An action of 'S' indicates that the program should subtract 1 from Variable1. When 'X' is specified for the action, it instructs the program to turn on *INLR, which causes the global variables to be reset. If the program is called again with one of the other action values after it is called with 'X', the value of Variable1 will be re-initialized. Our TEST activation group, however, will continue to remain in existence until it is reclaimed using the RCLACTGRP command. This can be seen by looking at the Display Activation Group screen, option 18 from the WRKJOB menu, as shown in Figure 2.

http://www.mcpressonline.com/articles/images/2002/ILEActivationGroupsV400062005.png

Figure 2: Any activation groups currently in existence are displayed on this screen. (Click image to enlarge.)

Similarly, opened files are kept open as long as the program is active and as long as the activation group remains in existence. The program shown in Figure 3 is an example of a program that accesses a database resource.

      *------------------------------------------------------------ 
      *                                      
      * Program: AGR002RG                           
      *                                                 
      * Description: Sample for Activation Groups         
      *                                                         
      * Compile Command: CRTBNDRPG PGM(xxx/AGR002RG)    
      *                            SRCFILE(xxx/QRPGLESRC)           
      *                            SRCMBR(AGR002RG)           
      *                            DFTACTGRP(*NO)      
      *                            ACTGRP(TEST)  
      *                                                               
      *------------------------------------------------------------    
     FCUSTOMERS IF   E             DISK    USROPN              
     C/FREE                                             
       If Not %Open(CUSTOMERS);              
         Open CUSTOMERS;                   
       EndIf;                                                  
       Read CUSTOMERS; 
       If %EOF;                 
         *INLR = *ON;                     
         Return;                   
       EndIf;                        
       Dsply CUSNAME;                              
       Return;                              
      /END-FREE                                

Figure 3: This program illustrates file use within an activation group.

Once again, this application is compiled to use the TEST named activation group. Each time the program is called, the program reads a record from the file CUSTOMERS and displays the value of the field CUSNAME. Once an end-of-file condition has been achieved, the program turns on *INLR.

In either of these examples, if the Reclaim Activation Group (RCLACTGRP) command is issued, any opened file pointers and static/global variables will be reset. If, for example, we called AGR002RG and then the RCLACTGRP was executed, the CUSTOMERS table would be closed. At this point, the activation group no longer appears in the Display Activation Groups screen. If AGR002RG is called again, the program will again create the activation group and will start with the first record in the CUSTOMERS table.

The same would be true of the global variable used in AGR001RG. When the activation group is reclaimed, the global variable will be reset, and a subsequent call to the program will recreate the activation group with newly initialized global variable values.

Similarly, the Reclaim Resources (RCLRSC) command can be used for programs running in the default activation group. These can be either OPM programs or ILE programs compiled with the option DFTACTGRP(*YES). The two parameters on the RCLRSC command are used to define the call level at which the cleanup should occur and to indicate whether an abnormal close notification should be sent to open communication files. Below is the syntax for the RCLRSC command.

RCLRSC LVL(*/*CALLER) OPTION(*NORMAL/*ABNORMAL)

The call level (LVL) parameter has an asterisk (*) option to identify that open resources at the current level or greater should be reclaimed. *CALLER can be specified to reclaim all resources at the level of the program that called the program issuing the RCLRSC command. Similarly the RCLACTGRP command accepts two parameters; however, the first parameter on this command is used to identify the activation group to be reclaimed. Below is the syntax for the RCLACTGRP command.

RCLACTGRP ACTGRP(*ELIGIBLE/Act Grp Name) OPTION(*NORMAL/*ABNORMAL)

The ACTGRP parameter is used to specify the name of the activation group to be reclaimed. The optional special value *ELIGIBLE can be specified to reclaim all eligible activation groups (that is, activation groups that are no longer in use). The OPTION parameter on this command not only handles sending an abnormal close notification to open communication files, but also determines whether to commit or roll back pending changes for an activation group level commitment definition.

Start Today!

While this discussion of activation groups has been at a fairly introductory level, I hope it has helped to give you the concept behind ILE activation groups. How you make use of this powerful ILE feature can greatly impact the performance and flow of your ILE programs.

Mike Faust is an application programmer for Fidelity Integrated Financial Solutions in Maitland, Florida. Mike is also the author of the books The iSeries and AS/400 Programmer's Guide to Cool Things and Active Server Pages Primer and SQL Built-in Functions and Stored Procedures. You can contact Mike at This email address is being protected from spambots. You need JavaScript enabled to view it..

Mike Faust

Mike Faust is a senior consultant/analyst for Retail Technologies Corporation in Orlando, Florida. Mike is also the author of the books Active Server Pages Primer, The iSeries and AS/400 Programmer's Guide to Cool Things, JavaScript for the Business Developer, and SQL Built-in Functions and Stored Procedures. You can contact Mike at This email address is being protected from spambots. You need JavaScript enabled to view it..


MC Press books written by Mike Faust available now on the MC Press Bookstore.

Active Server Pages Primer Active Server Pages Primer
Learn how to make the most of ASP while creating a fully functional ASP "shopping cart" application.
List Price $79.00

Now On Sale

JavaScript for the Business Developer JavaScript for the Business Developer
Learn how JavaScript can help you create dynamic business applications with Web browser interfaces.
List Price $44.95

Now On Sale

SQL Built-in Functions and Stored Procedures SQL Built-in Functions and Stored Procedures
Unleash the full power of SQL with these highly useful tools.
List Price $49.95

Now On Sale

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: