Activation Groups and ILE Concepts
Activation Groups and ILE Concepts
Activation Groups and ILE Concepts
Advantages of ILE:
Activation Groups:
Activation group is the environment where the ILE jobs are executed. You can specify
the activation group in CRTPGM or CRTSRVPGM command.
There are three possible values for Activation Group parameter.
1.Name, 2.New and 3.Caller.
You cannot create the activation group by command CRTACTGRP.
For the program activation group is : Name, Default activation group(*NO)if to use ILE
goodies, or Yes for OPM model.
For service program, DFTACTGRP(*Caller), can be *NEW or by name.
Activation group is a substructure of job and the substructure contains the resources
required for successful execution of program.
Currently, ILE activation groups can only be created implicitly. When you create an ILE
program, you specify the activation group in which the program will run on the
ACTGRP parameter. If, when the program is called, the activation group does not yet
exist, it will be created automatically by the system. (Remember, the default
activation group is created when the job is started.) It is important to keep in mind
that an activation group is part of a job; it cannot be accessed by other jobs.
ILE activation groups have many benefits over the default activation group:
Protection of shared resources from other programs and applications.
Resources such as shared open data paths for files, can be shared among all
programs in activation group, while being protected from other programs running in
the same job. Scoping (Restricting) of file overrides and commitment control scope.
Easy to cleanup a group of programs, You can clean up active programs and open files
with in an activation group using the RCLACTGRP command. Other active programs
running in the same job will not be affected.
A subprocedure is a procedure specified after the main section. It can only be called
using a bound call.
Subprocedure do not use the RPG cycle while running. All subprocedures have a
corresponding PROTOTYPE in the D-spec which ensures proper procedure or program
call with correct parameters. Subprocedure without a main procedure is called a
NOMAIN module.
You can pass parameters to a subprocedure. Names defined in the subprocedure are
not visible outside the subprocedure.
msreddy Page 1
You can call subprocedure recursively.
CALLB and CALLP are static calls. A module is a non-executable program and it
contains one or more procedures. If you have modules without procedure then it
means that it is having only one default procedure and in case we can use CALLB.
A module is having more than one procedure then we can give explicitly the
procedure name to be called in case of CALLP out of these three CALLP is the most
efficient one. (Using the CALLB, CALLP a program or module is bind in the program so
it is static.)
CALLP is the best call to use because it best captures the ideas of encapsulation,
inheritance and binding. That is, CALLP is a more natural opcode for use with modern
programs. Like EXSR, a CALLP executes some functional code that is intended to be
executed more than once. But where the code in a subroutine is all global, the code in
a procedure is private which means that procedures are much like the opcodes that
we use. We expect them to work certain ways, knowing what to pass in, and what
should be expected in return with almost no regard for the code being executed under
the covers. Though CALLP should be the main CALL, I think there may still be cases for
using CALLB. It's shop-dependent & standards-dependent.
From a CL, you can call the Windows standard calculator program.
PGM
STRPCO PCTA(*YES)
STRPCCMD PCCMD('C:WINNTSYSTEM32CALC.EXE')
ENDPGM
You can call any PC .EXE object as long as you know the path! The STRPCO command
is part of Client Access, which most iSeries shops have. (I'm not sure if my tip will work
without Client Access.)
Commitment Control:
Commitment control is used to process file operations as a group.
Commitment control is to save set of transactions done on a file.
msreddy Page 2
you to define and process a no of changes to database files as a single
unit (transaction).
QS40074 What are all the system objects required for journaling?
AS40074 Journal receiver, journal and PFs to be journal led.
QL40199 How do you use commitment control in RPG program ?
AL40199 Using COMIT operation.
Makes all changes to the files that have been specified in output
operation since the previous COMIT or the beginning of operations under
commitment control(if there has been no previous COMIT or ROLBK
operation).
Step1
First create the journal receiver:
CRTJRNRCV JRNRCV(MYJRNRCLIB/MYJRNRCV)
Step2
Next, create the journal specifying the journal receiver created above:
CRTJRN JRN(MYLIB/MYJRN) JRNRCV(MYJRNRCLIB/MYJRNRCV)
Step3
And, finally, start journaling on the physical file:
CRTJRNRCV
1. Be sure to:
o Place the journal receiver in a library that is saved regularly.
o Choose a journal receiver name that can be used to create a naming
convention for future journal receivers, such as RCV0001. You can use
the *GEN option to continue the naming convention when you change
journal receivers. This type of naming convention is also useful if you
choose to let the system manage the changing of your journal receivers
CRTJRN
1. Be sure to:
o Specify the name of the journal receiver that you created in the first step.
o Use the Manage receiver (MNGRCV) parameter to have the system
change the journal receiver and attach a new one when the attached
receiver becomes too large. If you choose this option, you do not need to
use the CRTJRN command to detach receivers and create and attach new
receivers manually.
o Specify DLTRCV(*NO) only if you have overriding reasons to do so (for
example, if you need to save these journal receivers for recovery
msreddy Page 3
reasons). If you specify DLTRCV(*YES), these receivers might be deleted
before you have a chance to save them.
You can use two values on the RCVSIZOPT parameter of the CRTJRN command
(*RMVINTENT and *MINFIXLEN) to optimize your storage availability and system
performance. See the AS/400 Programming: Performance Tools Guide for more
information.
STRJRNPF
1. Start journaling the source table using the Start Journal Physical File (STRJRNPF)
command, as in the following example:
2. STRJRNPF FILE(library/file)
3. JRN(JRNLIB/DJRN1)
4. OMTJRNE(*OPNCLO)
5. IMAGES(*BOTH)
6.
Specify the name of the journal that you created in step 2. The Capture program
requires a value of *BOTH for the IMAGES parameter.
The data integrity can be maintained using commitment control
STRCMTCTL LCKLVL(*CHG)
CALL PGM(*LIBL/CCTEST2)
COMMIT
CALL PGM(*LIBL/CCTEST2)
ROLLBACK
ENDCMTCTL
RETURN
ENDPGM
msreddy Page 4
Two-phase commitment control ensures that committable resources, such as
database files on multiple systems, remain synchronized.
Transactions
A transaction is a group of changes that appear as a single change, such as the
transfer of funds from a savings account to a checking account. Transactions can be
classified as follows:
• Inquiries in which no file changes occur.
• Simple transactions in which one file is changed each time you press the Enter
key.
• Complex transactions in which two or more files are changed each time you
press the Enter key.
• Complex transactions in which one or more files are changed each time you
press the Enter key. These changes represent only part of a logical group of
transactions.
Revisions made to files during transaction processing are journalled when using
commitment control.
If the system or job ends abnormally, journaling alone can ensure that, at most, only
the very last record change is lost. However, if the system or job ends abnormally
during a complex transaction, the files reflect an incomplete logical transaction. For
example, the job may have updated a record in file A, but before it updated a
corresponding record in file B, the job ended abnormally. In this case, the logical
transaction consisted of two updates, but only one update completed before the job
ended abnormally.
Benefits of using commitment control
Recovering a complex application requires detailed application knowledge. Programs
cannot be restarted. For example, record changes may have to be made with an
application program or data file utility to reverse the files to just before the last
complex transaction began. This task becomes more complex if multiple users were
accessing the files at the same time.
Commitment control helps solve these problems. Commitment control locks records
from other users during a complex transaction. This ensures that other users do not
use the records until the transaction is complete. At the end of the transaction, the
program issues the commit operation, freeing the records. However, should the
system end abnormally before performing the commit operation, all record changes
for that job since the last time a commit operation occurred are rolled back. Any
affected records that are still locked are then unlocked. In other words, database
changes roll back to a clean transaction boundary.
Service Programs:
Hi guys,
there is one module which included in one service program has been updated. so do I
need to update/re-compile all those programs which use the service program?
1. What about if the service program is standing alone?
2. What about if the service program is included in one binding directory?
msreddy Page 5
You won't need to rebind if the procedures that are imported have the same
parameters and the procedures are in the same order. The signature should then be
the same.
The signature can be thought of like a ‘format-level identifier’ of a file. When a file’s
format-level ID changes, you have to recompile programs that use the file or be
prepared for a “format level check” error. The format of the file has changed in a way
that makes it incompatible with previous versions.
Module:
Binding Directory:
A binding directory contains the names of modules and service programs that you
may need when creating an ILE program or service program. Modules or service
programs listed in a binding directory are used only if they provide an export that can
satisfy any currently unresolved import requests. A binding directory is a system
object that is identified to the system by the symbol *BNDDIR.
CPF9999 will also catch other messages that are not prefixed with CPF. MCH messages might occur and
CPF9999 will catch those whereas CPF0000 will not.
The 0 character is treated as a wild card for the purposes of error monitoring, so CPF0000 says to
monitor for any error.
msreddy Page 6
First, you can monitor for a specific message, e.g.:
MONMSG MSGID(CPF9801)
Next, you can monitor for a whole group of related messages, using a
"generic" designation such as:
MONMSG MSGID(CPF9800)
-- this will trap any message that begins with CPF98xx.
Next, you can monitor for a truly generic message, such as:
MONMSG MSGID(CPF0000)
-- this will trap any message that begins with CPFxxxx.
-- typically this is used in a "global message monitor" statement at the start of the program, e.g.:
MONMSG MSGID(CPF0000 MCH0000) EXEC(GOTO ERROR)
For these message IDs to be considered a "generic pattern" it must end in "00" or "0000".
The Retrieve Job Attributes (RTVJOBA) command is used in a CL program and TYPE attribute will tell Batch or
Interactive. ‘0’ indicates that the job is running as a batch job, and ‘1’ indicates an interactive job.
Trigger Programs:
Exit programs:
Must have experience with iSeries Security and how to use to ensure system security?
INFDS, *PSDS??
PSDS - A program status data structure (PSDS) can be defined to make program exception/error
information available to an RPG IV program. The PSDS must be defined in the main source
section; therefore, there is only one PSDS per module. A data structure is defined as a PSDS by an S in
position 23 of the data structure statement. A PSDS contains predefined subfields that provide you with
information about the program exception/error that occurred.
INFDS – A file information data structure (INFDS) can be defined for each file to make file exception/error
and file feedback information available to the program. The file information data structure, which must be
unique for each file, must be defined in the main source section. The same INFDS is used by all procedures
using the files.
msreddy Page 7
To handle File exception errors.
Create the data queue by using the Create Data Queue (CRTDTAQ) command.
Clear Data Queue (QCLRDTAQ) clears all entries from a data queue.
Receive Data Queue (QRCVDTAQ) receives data from the specified data queue.
Retrieve Data Queue Description (QMHQRDQD) retrieves information about a data queue.
Retrieve Data Queue Message (QMHRDQM) retrieves an entry from a data queue without
removing the entry.
Send to a Data Queue (QSNDDTAQ) sends data to the specified data queue.
Which is a subfile record format keyword. If you perform read on the subfile, the internal indicator
MDT (modified data tag) is automatically set off by the system. If you again perform read on the
same records, records won't be read. Because internal indicator MDT would be off. Hence you
should be explicitly set on the MDT by SFLNXTCHG keyword.
msreddy Page 8
PSDS
A program status data structure (PSDS) can be defined to make program exception/error information
available to an RPG IV program. The PSDS must be defined in the main source section; therefore,
there is only one PSDS per module.
A data structure is defined as a PSDS by an S in position 23 of the data structure statement. A PSDS
contains predefined subfields that provide you with information about the program exception/error that
occurred. The location of the subfields in the PSDS is defined by special keywords or by predefined
From and To positions. In order to access the subfields, you assign a name to each subfield. The
keywords must be specified, left-adjusted in positions 26 through 39.
Information from the PSDS is also provided in a formatted dump. However, a formatted dump might
not contain information for fields in the PSDS if the PSDS is not coded, or the length of the PSDS does
not include those fields. For example, if the PSDS is only 275 bytes long, the time and date or
program running will appear as N/A. in the dump, since this information starts at byte 276.
Link to what IBM says
msreddy Page 9
o Code Condition
o 00000 No exception/error occurred
o 00001 Called program returned with the LR indicator on.
o
o Exception/Error Codes
o
o Code Condition
o 00100 Value out of range for string operation
o 00101 Negative square root
o 00102 Divide by zero
o 00103 An intermediate result is not large enough to
o contain the result.
o 00104 Float underflow. An intermediate value is too
o small to be contained in the intermediate
o result field
o 00112 Invalid Date, Time or Timestamp value.
o 00113 Date overflow or underflow. (For example, when
o the result of a Date calculation
o results in a number greater than HIVAL or less
o than LOVAL.)
o 00114 Date mapping errors, where a Date is mapped from a
4
o character year to a 2 character year and the date
range
o is not 1940-2039.
o 00120 Table or array out of sequence.
o 00121 Array index not valid
o 00122 OCCUR outside of range
o 00123 Reset attempted during initialization step of
program
o 00202 Called program or procedure failed; halt indicator
o (H1 through H9) not on
o 00211 Error calling program or procedure
o 00222 Pointer or parameter error
o 00231 Called program or procedure returned with halt
o indicator on
o 00232 Halt indicator on in this program
o 00233 Halt indicator on when RETURN operation run
o 00299 RPG IV formatted dump failed
o 00333 Error on DSPLY operation
o 00401 Data area specified on IN/OUT not found
o 00402 PDA not valid for non-prestart job
o 00411 Data area type or length does not match
o 00412 Data area not locked for output
o 00413 Error on IN/OUT operation
o 00414 User not authorized to use data area
o 00415 User not authorized to change data area
o 00421 Error on UNLOCK operation
o 00425 Length requested for storage allocation is out of
range
o 00426 Error encountered during storage management
operation
o 00431 Data area previously locked by another program
o 00432 Data area locked by program in the same process
o 00450 Character field not entirely enclosed by shift-out
o and shift-in characters
o 00501 Failure to retrieve sort sequence.
o 00502 Failure to convert sort sequence.
o 00802 Commitment control not active.
o 00803 Rollback operation failed.
msreddy Page 10
o 00804 Error occurred on COMMIT operation
o 00805 Error occurred on ROLBK operation
o 00907 Decimal data error (digit or sign not valid)
o 00970 The level number of the compiler used to generate
o the program does not agree with the level number
o of the RPG IV run-time subroutines
o 09998 Internal failure in ILE RPG/400 compiler or in
o run-time subroutines
o 09999 Program exception in system routine.
INFDS
A file information data structure (INFDS) can be defined for each file to make file
exception/error and file feedback information available to the program. The file
information data structure, which must be unique for each file, must be defined in the
main source section. The same INFDS is used by all procedures using the files.
Link to what IBM says
msreddy Page 11
D SpclStat 38 42S 0 * SPECIAL
status
D RecordFmt *RECORD * Record
name
D MsgID 46 52 * Error
MSGID
msreddy Page 12
D OPERATION 260 260 * Cuurent
operatio
D IO_RCD_FMT 261 270 * Rcd format name
D DEV_CLASS 271 272 * Device class
D IO_PGM_DEV 273 282 * Pgm device name
D IO_RCD_LEN 283 286I 0 * Rcd len of I/O
msreddy Page 13
D LCL_NETID_P 310 317 * Local net ID
D RMT_LU_P 318 325 * Remote LU
D RMT_NETID_P 326 333 * Remote net ID
D APPC_MODE_P 334 341 * APPC Mode
D LU6_STATE_P 345 345 * LU6 conv state
D LU6_COR_P 346 353 * LU6 conv
* correlator
* The following fields apply to ISDN.
D ISDN_LEN 385 386I 0 * Rmt number len
D ISDN_TYPE 387 388 * Rmt number type
D ISDN_PLAN 389 390 * Rmt number plan
D ISDN_NUM 391 430 * Rmt number
D ISDN_SLEN 435 436I 0 * sub-addr len
D ISDN_STYPE 437 438 * sub-addr type
D ISDN_SNUM 439 478 * Rmt sub-address
D ISDN_CON 480 480 * Connection
D ISDN_RLEN 481 482I 0 * Rmt address len
D ISDN_RNUM 483 514 * Rmt address
D ISDN_ELEN 519 520 * Extension len
D ISDN_ETYPE 521 521 * Extension type
D ISDN_ENUM 522 561 * Extension num
D ISDN_XTYPE 566 566 * X.25 call type
D* Disk
D FDBK_SIZE 367 370I 0 * Size of DB fdbk
D JOIN_BITS 371 374I 0 * JFILE bits
D LOCK_RCDS 377 378I 0 * Nbr locked rcds
D POS_BITS 385 385 * File pos bits
D DLT_BITS 384 384 * Rcd deleted
bits
msreddy Page 14
D NUM_KEYS 387 388I 0 * Num keys (bin)
D KEY_LEN 393 394I 0 * Key length
D MBR_NUM 395 396I 0 * Member number
D DB_RRN 397 400I 0 * Relative-rcd-
num
D KEY 401 2400 * Key value (max
D* * size 2000)
D* ICF
D ICF_AID 369 369 * AID byte
D ICF_LEN 372 375I 0 * Actual data len
D ICF_MAJOR 401 402 * Major ret code
D ICF_MINOR 403 404 * Minor ret code
D SNA_SENSE 405 412 * SNA sense rc
D SAFE_IND 413 413 * Safe indicator
D RQSWRT 415 415 * Request write
D RMT_FMT 416 425 * Remote rcd fmt
D ICF_MODE 430 437 * Mode name
D* Display
D DSP_FLAG1 367 368 * Display flags
D DSP_AID 369 369 * AID byte
D CURSOR 370 371 * Cursor location
D DATA_LEN 372 375I 0 * Actual data len
D SF_RRN 376 377I 0 * Subfile rrn
D MIN_RRN 378 379I 0 * Subfile min rrn
D NUM_RCDS 380 381I 0 * Subfile num
rcds
D ACT_CURS 382 383 * Active window
D* * cursor
location
D DSP_MAJOR 401 402 * Major ret code
D DSP_MINOR 403 404 * Minor ret code
msreddy Page 15