Skip to main content

What is Activation Group?

Activation Groups on IBM i:

Activation group works like a Sub environment which allows sharing the open resources and/or overrides with across programs called in the Activation Group. 

Activation groups are one of important concepts on ILE on IBM i and makes it different from OPM in terms of how resources are shared with calling programs. 

E.g.:

We will consider a scenario of Batch Job which processes pending transactions in a Specific Application. 

Driver Program of Batch Job can create Overrides (OVRDBF) and/or Open Query (OPNQRYF) on a file with a set of conditions and calls multiple programs for processing different transactions. 

Considering the Overrides are created to share the resources across Activation Group (*ACTGRP), Result set of table (on top of OPNQRYF) would be made available to all the programs called in the specific activation group and avoids the need to perform override in every program.

When a program is created, we can choose on how the program needs to be run (in terms of Activation Group).
  • Default Activation Group
  • New Activation Group
  • Caller Activation Group
  • Named Activation Group
  • QILE/QILETS
We will see about each of these in detail.

Default Activation Group (DFTACTGRP):

This Keyword specifies whether program needs to run in the Default Activation Group of a Specific Activation Group.
  • When *YES is specified, Program will always run in the Default Activation Group. This option makes the program to run like OPM. This would also mean we cannot use BNDDIR or ACTGRP while creating the Program 
  • When *NO is specified, Program will be associated with the Activation Group mentioned in ACTGRP keyword. This is very useful in order to take the advantage of most of the ILE concepts. 
E.g.: DFTACTGRP keyword on CRTBNDRPG
CRTBNDRPG PGM(NEWPGM) SRCFILE(SRCLIB/QRPGLESRC) DFTACTGRP(*YES)

CRTBNDRPG PGM(NEWPGM) SRCFILE(SRCLIB/QRPGLESRC) DFTACTGRP(*NO) ACTGRP(*NEW)

New Activation Group (*NEW):

Specifying '*YES' on DFTACTGRP Keyword would allow the programmer to specify required Activation Group in ACTGRP parameter. 

'*NEW' would create the new activation group every time the Program is called. And, System would randomly create Activation group name and cannot be specified by programmer.

If the Program is called by two different users at the same time, Two new Activation Groups are created.

Caller Activation Group (*CALLER):

'*CALLER' on ACTGRP would make the program to run under the Activation Group determined by the Calling program. 

E.g.: If PGM2 is compiled with ACTGRP(*CALLER), PGM1 is compiled with ACTGRP(*NEW) and PGM2 is called from PGM1,

When PGM1 is called, System would create new Activation Group and when PGM2 is called, PGM2 will run under the same Activation Group (created by PGM1).

Named Activation Group:

Name of the Activation Group can be determined the Programmer as required by Application. 
CRTBNDRPG PGM(NEWPGM) SRCFILE(SRCLIB/QRPGLESRC) DFTACTGRP(*NO) ACTGRP(ACT1)
If the Application is to run under specific Activation group, Driver program for the program for the application can be compiled with specific Name in Activation Group and the calling programs can be compiled using ACTGRP(*CALLER)

QILE/QILETS:

QILE/QILETS are the Activation groups created by IBM. These can be used if there is no specific requirement for Activation group and to utilize the advantages of ILE concepts (as Default Activation Group makes the program to behave like OPM).

  • Q denotes this is Activation Group created by IBM.
  • ILE denotes to Integrated Language Environment.
  • TS denotes to Teraspace.

QILE/QILETS cannot be directly specified by the programmer. Storage Model (STGMDL) would determine if the program needs to compile with QILE or QILETS. Below are the possible options for Storage Model.
  • *SNGLVL - The program is created with single-level storage model.  When a single-level storage model program is activated and run, it is supplied single-level storage for automatic and static storage. A single-level storage program runs only in a single-level storage activation group.
  • *TERASPACE - The program is created with teraspace storage model.  When a teraspace storage model program is activated and run, it is supplied teraspace storage for automatic and static storage. teraspace storage program runs only in a teraspace storage activation group.
  • *INHERIT - The program is created with inherit storage model. When activated, Program adopts the storage model it is activated into. When this is selected, ACTGRP(*CALLER) must be selected.
If STGMDL(*TERASPACE) is specified, the program will be activated into the QILETS activation group when it is called. Otherwise this program will be activated into the QILE activation group when it is called.

CRTBNDRPG PGM(NEWPGM) SRCFILE(SRCLIB/QRPGLESRC) DFTACTGRP(*NO) 
ACTGRP(*STGMDL) STGMDL(*TERASPACE)

Comments

Popular posts from this blog

All about READ in RPGLE & Why we use it with SETLL/SETGT?

READ READ is one of the most used Opcodes in RPGLE. As the name suggests main purpose of this Opcode is to read a record from Database file. What are the different READ Opcodes? To list, Below are the five Opcodes.  READ - Read a Record READC - Read Next Changed Record READE - Read Equal Key Record READP - Read Prior Record READPE - Read Prior Equal Record We will see more about each of these later in this article. Before that, We will see a bit about SETLL/SETGT .  SETLL (Set Lower Limit) SETLL accepts Key Fields or Relative Record Number (RRN) as Search Arguments and positions the file at the Corresponding Record (or Next Record if exact match isn't found).  SETGT (Set Greater Than) SETGT accepts Key Fields or Relative Record Number (RRN) as Search Arguments and positions the file at the Next Record (Greater Than the Key value). Syntax: SETLL SEARCH-ARGUMENTS/KEYFIELDS FILENAME SETGT  SEARCH-ARGUMENTS/KEYFIELDS FILENAME One of the below can be passed as Search Arguments. Key Fiel

What we need to know about CHAIN (RPGLE) & How is it different from READ?

CHAIN READ & CHAIN, These are one of the most used (& useful) Opcodes by any RPG developer. These Opcodes are used to read a record from file. So, What's the difference between CHAIN & READ?   CHAIN operation retrieves a record based on the Key specified. It's more like Retrieving Random record from a Database file based on the Key fields.  READ operation reads the record currently pointed to from a Database file. There are multiple Opcodes that start with READ and all are used to read a record but with slight difference. We will see more about different Opcodes and How they are different from each other (and CHAIN) in another article. Few differences to note.  CHAIN requires Key fields to read a record where as READ would read the record currently pointed to (SETLL or SETGT are used to point a Record).  If there are multiple records with the same Key data, CHAIN would return the same record every time. READE can be used to read all the records with the specified Ke

Extract a portion of a Date/Time/Timestamp in RPGLE - IBM i

%SUBDT Extracting Year, Month, Day, Hour, Minutes, Seconds or Milli seconds of a given Date/Time/Timestamp is required most of the times.  This can be extracted easily by using %SUBDT. BIF name looks more similar to %SUBST which is used to extract a portion of string by passing from and two positions of the original string. Instead, We would need to pass a value (i.e., Date, Time or Timestamp ) and Unit (i.e., *YEARS, *MONTHS, *DAYS, *HOURS, *MINUTES, *SECONDS or *MSECONDS) to %SUBDT.  Valid unit should be passed for the type of the value passed. Below are the valid values for each type. Date - *DAYS, *MONTHS, *YEARS Time - *HOURS, *MINUTES, *SECONDS Timestamp - *DAYS, *MONTHS, *YEARS, *HOURS, *MINUTES, *SECONDS, *MSECONDS Syntax: %SUBDT(value : unit { : digits { : decpos} }) Value and Unit are the mandatory arguments.  Digits and Decimal positions are optional and can only be used with *SECONDS for Timestamp. We can either pass the full form for the unit or use the short form. Below i