Sie sind auf Seite 1von 14

ILE

1) Binding
2) Modularity
3) Reusable components
4) Common Run time services (Service programs)
5) Better control over resources (Activation groups)
6) Better code optimization
7) Foundation for the future

Module Object:

Debug Data
PEP: (Program Entry Procedure)
UEP: (User Entry Procedure)

Debug data is the data necessary for debugging a runable ILE object and
is optional.
PEP Program Entry Procedure is the compiler generated code that is the
entry point of an ILE program on a dynamic call. The system adds some
code to initialize the module.
UEP User Entry Procedure is written by the programmer is the target of
the dynamic program call. It is the procedure that gets control from
PEP.

When the create program CRTPGM, is specified the ENTMOD parameter allows
you to select which module containing a PEP is the programs entry point. A PEP
that is associated with a module that is not selected as an entry point for the
program is ignored. All other procedures and data items of the module are used
as specified and only the PEP is ignored.

Program Object:-

1) Single Module programs

CRTBNDRPG or 14

2) Multiple Module programs

CRTxxxMOD (15) then CRTPGM (14)

Notes By Shivraj Tekale


CRTBNDRPG creates a module object in the QTEMP library and is deleted at the
end of the job. CRTBNDRPG provides a single step approach to program
creation.

In case of multiple module programs ILE supports 2 types of static binding. In


case of Bind by copy the module containing the procedure code is copied into a
new program object. When the program is created the system copies the
necessary code to make the program object executable. This code is known as
PEP. This is the entry point for an ILE program. In a *PGM many modules have
UEPs. You specify which one is the UEP for your program object in the ENTMOD
parameter.

CALL & CALLB

CALL
*PGM
Dynamic Binding
ILE or OPM

CALLB
Bound Procedure
Static Binding
Module

Why Service Program??

Bind by Copy
Many copies of code
Complex Maintenance

Service Programs
Single Copy of code
Similar to subroutine or procedure library

Call performance is similar in both.

A service program is a collection of runnable procedures and available data


items easily & directly accessible by other ILE programs or service programs.

Creating Service programs:

Source Member
Modules
CRTSRVPGM

Notes By Shivraj Tekale


To create a service program, you must first create the modules that are to be
copied into the service program. One or more modules from any ILE language
are copied to make the service program object. Then you run the CRTSRVPGM
command. The *SRVPGM object is not executable but contains a set of callable
procedures. There is no PEP associated with *SRVPGM. Since no PEP a dynamic
program call to a service program is not valid. A modules PEP is ignored.

HITECH Lets look at the real time scenario:-

Updation

CRTXXXMOD
UPDPGM

Service Program
CRTXXXMOD
UPDSRVPGM

To update a procedure that is bound by copy, you must recreate the module
using CRTXXXMOD command. Then rebind the changed module to all *PGMs that
require it using the UPDPGM command. You can also use CRTPGM to achieve
the same. The difference is that the UPDPGM command requires the name of
the *PGM and the name of the modules only that are to be replaced.

Like the UPDPGM command, UPDSRVPGM takes a changed module and replaces
the existing module to create a new copy of the service program.

Binding Directory:-

CRTBNDDIR
ADDBNDDIRE

Objname type lib


QALLOC *SRVPGM *LIBL
QMATH *SRVPGM QSYS
QFREE *MODULE *LIBL
QHFREE *SRVPGM XYZ

A binding directory contains the name of the modules & service programs that
you may need when creating an ILE program or service program.
A Binding Directory is a system object that is identified to the system by the
symbol *BNDDIR. The Binding directory is optional, but reduces the number of
parameters you must enter when creating a *PGM or *SRVPGM. It eliminates the
possibility of making error such as keying a wrong *MODULE name.

Notes By Shivraj Tekale


WRKBNDDIR command allows you to display and work with the list of binding
directories.

IMPORT & EXPORT Procedure:-

Import
CALLB to procedure not bound by copy
Reference to procedure outside real module of *PGM or *SRVPGM

Export
Make procedure available to be called from outside this *SRVPGM

When you import a procedure you are calling this procedure that is not bound
by copy to this *PGM object an import can also be called as reference. An
import request is made when you bind by reference to a *SRVPGM

When you export a procedure in ILE, you make it available to be bound by


reference to procedures outside this *PGM or *SRVPGM object. An export can
also be called as the definition. A procedure is made available for export when
you specify the export keyword in the prototype.

CALL OPCODES

1) CALL Dynamic Call


2) CALLB Static Bound Call
3) CALLP In place of CALL or CALLB, Prototyped parameters

CALL: - At the runtime, compiler is going to check for the existence of the
object.

CALLB: - Compiler checks for the existence of the object at the compile
time.

CALLP: - eval res = proc1(x: y: z)


Here, instead of PLIST we can send parameters directly.

You have used CALL and parameter lists to access other program objects. By
using CALLB you save time because the code of the other module is statistically
bound to the calling program. The parameters are defined using an interface
called prototype. CALLP is one type of prototyped call.

If procedure is not returning any value we just use CALLP, but if returning any
value we use expression.

Notes By Shivraj Tekale


PGM1 PGM2

Module1 Module 4
P5
- P1
- P2
Module2
- P3
Module3 Service Program:-
- P4
*Module sp1
============
Subprocd sp1
P
D
*MODULE SP1 C
RPG P
Sub procedure SP1
Source
P *Module sp2
Mbr1
D Subprocd sp2
SP1
C P
P D
C
P
*Module sp3
Subprocd sp3
P
D
C
P

The best way to package sub procedures is in a service program. The steps
while creating are:

1) Code the Sub procedure source members, type RPGLE. Each sub
procedure contains P spec, D spec, C spec.
2) Use CRTRPGMOD to create a compile unit for each individual sub
procedure.
3) Use CRTSRVPGM to place all desired sub procedure modules in a
*SRVPGM object.
4) You will be able to call all sub procedures from modules bound to your
service program.

Note: - A service program will have N number of modules and all modules can
have N number of procedures.

Notes By Shivraj Tekale


Binder Language

Binder Language makes sub procedures, procedures and data names available
for use by other *PGM & *SRVPGM objects by making them available for export.
Service program stores latest signature, binder language has many signatures.
So Binder language is used to store more than one signature for a particular
program or module object. Ex: - Here, Binder Language is stored in QSRVSRC
source file & generally the member name will be the name of the service
program.

Source File QSRVSRC.Finance *PRV for old signatures

STRPGMEXP PGMLVL (*CURRENT) LVLCHK (*YES)


EXPORT SYMBOL (TERM)
EXPORT SYMBOL (RATE)
EXPORT SYMBOL (AMOUNT) Export Procedures
EXPORT SYMBOL (PAYMENT) &
EXPORT SYMBOL (OPENACCT) data items
EXPORT SYMBOL (CLOSEACCT)

Signatures:-

A signature is a value that identifies the public interface supported by the


service program. It is similar to level check on the AS/400 file object. You may
specify your own explicit signature or the binder will generate a signature
based on the list of the procedures and the data item names to be exported
and the sequence in which they are specified. Therefore a signature provides a
quick & convenient way to validate accessibility to the service program. The
level check parameter on the STRPGMEXP command specifies during the
binding process, the public interface to the service program should be checked.
The signature is generated when the service program is created. The signature
is copied to every *PGM object that binds by reference to that service program
when the *PGM is created. When the bind is completed at program load, the
signatures
Module 1 are checked, if the signature match the client referencing the
Financial
service program can use the public interface with out being recompiled.
CALLPRC payment *SRVPGM
Term Finance
Rate
Amount
Payment
Open Acct
Clos Acct

Notes By Shivraj Tekale


Payment =4th slot Current Signature =
Signature = Sig 123 Sig 123
OPM Model

- RPG III
- Basic
- CL
- PL/I
- COBOL

Extended Program Model

- C
- PASCAL

ILE Model (Integrated Language Environment)

- RPGIV
- C
- COBOL

OPM:-
Original Program Model is an integral part of OS/400. In OPM Model the
program call is dynamic (CALL) that means at run time the program is going to
check for the existence of the object. The variables are public across the
entire program. On every compilation of a source program it creates a program
object. There is only one entry point and the resources are shared across the
job.

EPM:-
In Extended Program model it has multiple entry point unlike OPM. The
variables are static or automatic. It is the layer above the OS/400 and thus it
creates an environment which is different, ideal for development of tools.

ILE:-

Notes By Shivraj Tekale


ILE is also tightly integrated with OS/400 like OPM. In ILE it supports static or
dynamic binding. It supports local variable and external variables. It integrates
traditional language like RPG & procedure based language like C into one
environment. This has resulted in a better run time behavior.

Activation Groups:-

A) Activation What is Activation?

- Unique Allocation
- Changes the symbol links

After creating a program object it is ready to be executed. The process of


getting a program or service program ready to run is called activation.
Activation is done by the system when the program is called. But we cannot
call a service program since no PEP, so they are activated during the call to a
program that directly or indirectly requires their services. Each activation will
be provided with one copy of static variables for each program activation. It
also changes the symbolic links to service programs providing the exports into
links to physical addresses.

Advantage: - No matter how many jobs are running a program or service


program, only one copy of that objects instruction resides in storage. So when
one program object is used concurrently by many jobs the static variables are
separate for each activation. All ILE programs and service programs are
activated with in an activation group.

B) Application Isolation

DFT AG
A

OE1 OE1 OE1

MENU
1. Order Entry
2. Stock Report Activation A

SR1 Notes
SR2 By Shivraj Tekale

A
Here, Order Entry & Stock Report are two applications.

An Activation Group is like a sub job. A job with in a job.

An Activation Group: - The method used to define Firewalls is called as


Activation Group. The programmer can request that this application run in an
unique activation group and that the resources (such as Data File, ODP) can be
scoped to that activation group.

2) Isolates applications with in a job for achieving


- Flexibility
- Scoping of File overrides and commitment control
- File sharing with in Activation Groups
1) Selective Cleanup of applications
2) Firewalls
3) Applications own resources
4) Less dependency on Job call stack

c) Program Activation OPM

1 2 3

Storage for PGMA Storage for PGMA Storage for PGMA


Storage for PGMB

4, 5 6, 7
Storage for PGMA Storage for PGMA

Storage for PGMC Storage for PGMB

Storage for PGMC


Notes By Shivraj Tekale
1) Call OPM program A, PGMA is activated.
2) PGMA calls OPM PGMB. Now PGMB is activated.
3) PGMB returns to PGMA with LR indicator ON. PGMB is deactivated.
4) PGMA calls ILE PGMC, PGMC is activated.
5) PGMC returns to PGMA with LR indicator OFF. PGMC is not deactivated.
6) PGMA calls OPM PGMB again, PGMB is activated.
7) PGMA calls ILE PGMC again, It now branches to PGMC (reactivation is
unnecessary) since PGMA called PGMC before and there was not set on
LR in PGMC at that time so it now branches to PGMC when called again
from PGMA.

Note: - From this it is clear that, Activation includes the initialization of static
storage. In OPM When a program ends, its activation is cleaned up.

Notes By Shivraj Tekale


d) Program Activation ILE

1 2 3

Storage for PGMA Storage for PGMA Storage for PGMA

Storage for PGMB Storage for PGMB *

4, 5 6, 7

Storage for PGMA


Storage for PGMB Storage for PGMA

Storage for PGMC Storage for PGMB

Storage for PGMC

Note: - The above is explained with the assumption that all ILE *PGMs will be
running in the same activation group.

Call ILE PGMA. The activation group is created if this the first call in the job.
PGMA is activated.

PGMA calls ILE PGMB. Now PGMB is activated in the same activation group.

PGMB returns to PGMA with LR indicator ON. PGMB is not deactivated, the
reinitialize flag is set.

PGMA calls PGMC. PGMC is activated in the same activation group.

PGMC returns to PGMA with LR indicator OFF. PGMC is not deactivated similar
to OPM.

PGMA calls PGMB again. PGMB is not reactivated, but initialized.

PGMA calls PGMC again. PGMC is not reactivated, but initialized.

Important Note (HITEC concentrate):- ILE activation remains in the activation


group in which it was initially activated for the life of that activation group,
even after that program ends. If you SETON LR implicitly closed files will be

Notes By Shivraj Tekale


closed and the static storage will be flagged for reinitialization on the next
call. But the storage is not deleted from the job.

e) Activation Groups

- ILE programs can run in ILE activation groups.


- OPM programs runs in default activation group
i) ILE programs can run in the default or ILE activation groups.
ii) Recommendation: ILE programs runs only in ILE activation groups.
- ILE activation groups have two major purposes
i) Protection of shared resources from other applications.
ii) Clean up of storage by ILE programs.

All ILE programs and sub programs are activated with in a substructure of a job
called an activation group. This contains the resources necessary to run the
programs.

Resources fall into the following general categories:


1) Static & dynamic program variables.
2) Dynamic storage.
3) Temporary data management resources.
4) Certain type of exceptional handlers & ending procedures.

Ex: - Data File, ODP

Imp Note: - Storage for ILE programs in a job cannot be cleaned up if they are
run in a default activation group. The default activation group cannot be
reclaimed. Therefore, ILE activation group remains for the life of the Job.
Other minor differences exist in the behavior that makes it unwise to mix OPM
& ILE programs in default activation groups. RCLRSC command does not reclaim
storage for ILE programs.

f) Activation group example

For diagram see Application Isolation topic

In the above diagram, Order entry application & Stock report application run in
its own activation groups OE & SR respectively. QILE is the generic activation
group name that may be used for those ILE applications that do not need to run
in their own activation groups.

Notes By Shivraj Tekale


The File A is shared resource (shared ODP). It is shared among all the programs
in OE activation group & a different shared ODP is setup for all the programs in
the SR activation group. The shared resource can be set across the job (all
activation groups) as well as only within an activation group.

g) Activation Group creation

Default Activation Group OS/400 system


Program X Program Y System code
activation activation Program activations

Program A Program B
activation activation

ILE ILE
Activation Group

When ever an OS/400 job is started, the system creates two default activation
groups to be used by OPM programs. One activation group is reserved for
system code & the other is used for all the OPM programs. You cannot delete
the OPM default activation groups. They are deleted by the system when the
job ends.

You can control the run time creation of an ILE activation group by specifying
an activation group attributed when you create your program or service
program. Based on the attribute an activation group is created by ILE as a part
of dynamic program call processing. The attribute is specified by using the
ACTGRP parameter on the CRTPGM command or CRTSRVPGM.

h) Activation Group attributes

Activation Groups are of three types

1) User named activation group


2) System named activation group
3) Activation group of the caller

Notes By Shivraj Tekale


Activation group attributes

- CRTPGM <F4> ACTGRP (*NEW)


- CRTSRVPGM <F4> ACTGRP (*CALLER)
- CRTBNDRPG <F4> DFTACTGRP(*YES)

User Named activation group: - A user named activation group allows you to
manage a collection of ILE program and ILE service program as one
application. The activation group is created when it does not already exist in
the job. It is then used by all the programs & service programs that specify
the same activation group name. This is specified with the ACTGRP
parameter. It creates a persistent activation group.

System Named activation group: - A system named activation group allows you
to create a new activation group when ever the program is called. ILE selects
a name for this activation group. The name assigned by ILE is unique with in
the job. The name assigned to the system named activation group does not
match any name you choose for a user named activation group. ILE service
programs do not support this attribute. This is specified with the ACTGRP
(*NEW) parameter on the CRTPGM command. It creates a non persistent
activation group.

Note: - ILE service programs do not support this attribute.

Activation group of the CALLER: - An attribute to use the activation group of


the calling program allows you to create an ILE program or ILE service
program that will be activated with in the activation group of the calling
program. With this attribute a new activation group is never created when the
program or service program is activated. This attribute is specified with
ACTGRP (*CALLER) parameter.

What is meant by Persistent activation Groups? HITEC Question

. Programmer named activation group or user named activation group.


- Exists until explicitly destroyed or End of Job.
- May be destroyed because of unhandled exception.
. Activation Group can be destroyed by
- RCLACTGRP
- Language specific Hard Leave operations
. COBOL: STOP Run
. C: exit () from main
- RPG & CL have no Hard Leave operations
. CALL to ILE API CEETREC
- Unhandled Exceptions.

Notes By Shivraj Tekale

Das könnte Ihnen auch gefallen