Beruflich Dokumente
Kultur Dokumente
Improve Modularity
Productivity
Benefits (contd...)
– Better environment for ‘C’
– Foundation for the future
ILE
Binding
Introduction :
IBM AS/400 Language Compilers
– OPM (Original Program Model)
– EPM (Extended Program Model)
– ILE (Integrated Language Environment)
ILE
OPM (Original Program Model)
Earliest language compilers on S/38 & AS/400
generated the MI instructions in a fairly direct manner
MI instructions were the intermediate form
The form of the program below MI is called the OPM
Supported design for RPG & COBOL
Offered limited support for Block Structured
Languages
Only CALL supported by MI is called external (or
dynamic) call
Supports only one language source per program
ILE
OPM
MI Instructions
MI Boundary
UCODE Optimizer
UCODE
C/400 COMPILER
ILE
ILE (Integrated Language Environment)
Service Program
– Executable code made up of one or more modules
– Activated as a unit
– Treated as a collection of procedure (kind of subroutine
library)
– Procedure is called with a Static CALL
– Can have Multiple Entry Point, one for each procedure
– Can’t be executed with dynamic call
ILE
Jargons
Activation Group
– Working storage within a Job
– Allocated to run one or more programs
Types of Static Call
– Bound by Copy
– Bound by Reference
ILE
Types of Static CALLS
Bound by Copy
– Multiple modules to be copied into a single program
– All procedure names are resolved to address at compile
time
– Much faster
– Memory utilization is more
– Better CALL performance
Bound by Reference
– Uses a service program to store the modules
– Stores program symbolic links to the module in the
service program
– Only single copy of service program
– Activated when links are resolved
ILE
Types of Static CALLS
What is a Process ?
– Single Unit of work
– Also called as TASKS
Handling by OPM
– Non modular program
– Process - Implemented at the MI
– Two parts of the object
System object
Process object
– Has control information
– Object contains storage areas
ILE
Process Management
Activation Group
– Replace both PSSA & PASA
– Each has its own control information
– Has different protection states, file usage &
commitment control
– Gives great deal of flexibility for jobs above MI
ILE
Concepts
Benefits (contd...)
– Better environment for ‘C’
– Foundation for the future
RPG IV and ILE
No re-engineering
Log
Audit trail
Project progress
Conversion Report Example
From file………………………….: RPGOLD
Library ……………………..: RJS
From member……………………..: RPGEX
SEQNBR *…1….+….2….+….3….+….4….+….5….+….6…
Conversion Listing
0000047 C* DEBUG
* RNM0517 DEBUG operation code not supported in RPG IV
Subprocedure Specifications
P - Procedure Specification
D - Definition Specification
C - Calculation Specification
H -Spec Changes
RPG/400
H........1..CDYI....S..............1.F...............................Pgm-id
H 1 $M/ S F MYPGM
RPG IV
HKeywords+++++++++++++++++++++++++++++++++++++++++++++++++++++
HALTSEQ(*EXT) CURSYM('$') DATEDIT(*MDY/) DATFMT(*MDY/)
HDEBUG DECEDIT('.') DFTNAME(MyPgm) TIMFMT(*ISO)
• Free Format
• Keyword driven
H-Spec Keywords
RPG IV
F-Spec Example
Keyword{(value)} Explanation
COMMIT Commitment Control fromF-Spec continuation
DEVID(fieldname) Programdev name replaces ID fromF cont.
EXTIND(*INU1-*INU8) External indicators replaces U1-U8 col 71-72
USROPN User controlled open-relaces UC cols 71-72
FORMLEN(number) Forms length for printer file fromL spec
OFLIND(*Inxx) Overflow indicator fromF_spec pos 33-34
FORMOFL(number) Overflow line printer file fromL spec
IGNORE(fmt_nm{:fmt_nm..}) Replaces IGNORE file continuation option
INFDS(Dsname) Replaces INFDS exception DS fromF cont.
INFSR(SUBRname) File exception subroutine fromF cont.
KEYLOC(number) Key location fromPos 35-38
MAXDEV(*ONLY/*FILE) *FILE replaces NUM on F continuation
F-Spec Keywords
Keyword{(value)} Explanation
PASS(*ONIND) User controlled indicator area fromF cont.
PLIST(Plist name) Parmlist for SPECIAL file fromF continuation
PGMNAME(program_name) Programto get control for SPECIAL file
PRTCTL(DSnm{:*COMPAT)}) Dynamic printer control fromF cont.
RECNO(fieldname) FromF continuation
RENAME(Ext.fmt:Int.fmt) FromF continuation (new format)
SAVEDS(Dsname) Replaces SAVDS fromF continuation
SAVEIND(number) Replaces INDfromF continuation
SFILE(recfmt_name:field) FromF continuation
SLN(number) FromF continuation
RAFDATA(filename) Replaces RAF file (fromE-spec)
New F-Spec Keywords
Keyword{(va lu e )} E xp la inatio n
COMM IT{(rp g _n a me ) C on dition alco m mitmentcontro l-o ptiona
lpa
rame
ter
INC
LU DE (fm t_n am e{:fm t_ nam e
… }) O pp o siteo fIG NOR E
PREFIX(p re fix
_n a me {:nb r_ chr_
repl})Atta tch esp refixton amesofa llfie
lds
ina llre co rdsofafile
DATFM T(fo rm a t{sep e rato r}) D efa u ltD atefo rma t+separa to r(opt.)
TIM
FM T(fo rm at{se para to r}) D efa u ltTim efo rma t+separa to r(opt.)
Current RPG/400
New RPG IV
I-Spec Changes
Data types of D, T, Z
No length required
Format separator may be defined (default ISO format
Literal values are D’date value’, T’time value’,
Z’timestamp value’
Defining Date and Time Formats
H-Spec
- Specify default internal format
- Defaults to *ISO
D-Spec
- Overrides H-Spec
- With INZ or CONST, H-Spec rules
C-Spec
- Factor 1 format for TEST, MOVE, MOVEL
- Moving data to/from date/time fields
Defining Date/Time/Timestamp Fields
Date Formats
DateFld = 04/15/99
TimeFld = 13:00:00
C-Spec Changes
Changed
CLEAR clear structure/variable/format
RESET reset structure/variable/format
Discontinued
DEBUG log debug information
FREE free subprogram storage
Extended Factor 2
Free-form Factor 2 (can be continued)
New Opcodes (DOW, DOU, IF, WHEN, EVAL)
New Operators
+ - * / = **
> < ( ) NOT OR AND
Using Expressions
Free- form used with Opcodes:
DOU, DOW, IF WHEN and EVAL
New operators
+ - * / = **
> < ( ) NOT OR AND
Use expanded Factor 2
No Factor 1
Opcode extender (H) on EVAL for numeric results
Different types of expressions
Using Expressions
Conditional
Arithmetic
C EVAL Counter= Counter+1
String
EVAL Result = A + B * C ** (X * Y)
Using Parentheses
Since ( ) are highest in precedence, use them to :
- Break up complex expressions
- Ensure accurate results
Exponentiation
Operation Code Extenders
Built-in Functions
- Trim spaces from character fields
- Refer to a substring of a field
- Return the size of a field
- Return the number of elements in an array
or multi-occurrence data structure
- Place the address of an item in a pointer variable
- Place the address of a procedure in a pointer variable
Pointers to base storage inside or outside your program
*MODULE X *PGM X
RPG CRTBNDRPG
Source Procedure Procedure
Mbr X X X
Creating RPG IV Programs
ILE program may contain 1 or more modules
For multiple module programs: CRTRPGMOD + CRTPGM
*MODULE A
Mbr B
*MODULE C
Program Data
ILE RPG/400 Module with Subprocedures
* MODULE
Main Procedure
Main H
Source F
D
Section I
C
O
Global
Subprocedure 1
P
D Local
C
P
Subprocedure 2
P
D
Part C
Local
of P
Main
Program Data
Source
Section
ILE RPG/400 Module NOMAIN
* MODULE
H NOMAIN
Subprocedure 1
P
D
C
P Local
Subprocedure 2
P
D
C
P Local
Subprocedure 3
P
D
C
P
Local
CALL Program vs. CALLB Procedure
CALL must target a *PGM object
- Invoke a dynamic bind at run time
- May be ILE or Original Program Model
*PGM A
*PGM X *PGM Y
Procedure Procedure Procedure
CALL Y CALL A A B C
CALLB ‘B’ CALLB ‘C’
Using Multiple ILE Languages
CL, COBOL and C will have ILE compilers
Modules from any ILE language can be bound to RPG IV programs
*MODULE A
Mbr B
*MODULE C
CL CRTRPGMOD Proc. C
Src
Mbr C
Service Programs
Problems with Bind by Copy
Multiple copies of frequently used routines
*MODULE X
Src MOD( X Y C)
Proc X Proc Y Proc C
Mbr B
*MODULE C
*SRVPGM J
*PGM A *PGM D
Procedure X
Procedure A Procedure B Procedure D
Procedure Y
CALL B CALL C CALL C
Procedure C
Bind
Bind
by Copy
by Reference
Bind by Copy and Reference
Bind by Reference
- Better suited for modules to be reused in many programs
- Parameters
- Type of Call
· P-Spec
- MAIN or NOMAIN
- EXPORT
· D-Spec
- Logic
- Return information to CALLER
Prototyped CALL
Includes
- Type of call (bound / dynamic)
- Name of procedure
- Parameter information
- Return value
Simple Call Prototype
CALLP via EVAL
CALLP Using RETURN
Recursive Calls
• Powerful Capability
• Either :
- Rebind with CRTPGM specifying all
modules/service programs needed
- UPDPGM to replace the affected module
Module D
PGM 1 PGM 3
PGM A
A
PGM B
Activation Group: QILE
PGMX PGMY
Programs 1,2 and 3 make up parts of the order
entry application. They have been designed to run
in the ORDENTRY activation group. They share
the open data path foe file A. Programs running in
any other Activation Group cannot get to data via
the specific ODP for file A in the ORDENTRY
Activation Group. It is “protected” by the
boundaries of the Activation Group.
Programs A and B are most likely
OPM (original program model), or
non-ILE programs because they are
running the in the default AG.
However, programs X and Y may each open
file A as separate non-shared ODP, or
programs X and Y could choose to share their
own copy of an open data path for file A in
their own Activation Group.
This protects the cursor position, open
attributes, etc, for the files specific to use for a
particular application from other programs in
the job that need access to the same file.
One copy of
Program A
program
Program Instructions instructions
JOB JOB
Variable X = 10 Variable X = 20
- Do not mix
- RPG IV can compile for default AG
- CRTBNDRPG ……….DEFACTGRP(*YES)
- CRTPGM has no option to direct to default AG
Recommendations
Complete Applications
Optimize use of ILE
Design run-time using AGs
Individual Programs
Compile for default AG
Be aware of limits
When done, look at full ILE
ILE
OPM
MI Instructions
MI Boundary
UCODE Optimizer
UCODE
C/400 COMPILER
ILE
ILE (Integrated Language Environment)
Service Program
– Executable code made up of one or more modules
– Activated as a unit
– Treated as a collection of procedure (kind of subroutine
library)
– Procedure is called with a Static CALL
– Can have Multiple Entry Point, one for each procedure
– Can’t be executed with dynamic call
ILE
Jargons
Activation Group
– Working storage within a Job
– Allocated to run one or more programs
Types of Static Call
– Bound by Copy
– Bound by Reference
ILE
Types of Static CALLS
Bound by Copy
– Multiple modules to be copied into a single program
– All procedure names are resolved to address at compile
time
– Much faster
– Memory utilization is more
– Better CALL performance
Bound by Reference
– Uses a service program to store the modules
– Stores program symbolic links to the module in the
service program
– Only single copy of service program
– Activated when links are resolved
ILE
Types of Static CALLS
What is a Process ?
– Single Unit of work
– Also called as TASKS
Handling by OPM
– Non modular program
– Process - Implemented at the MI
– Two parts of the object
System object
Process object
– Has control information
– Object contains storage areas
ILE
Process Management
Activation Group
– Replace both PSSA & PASA
– Each has its own control information
– Has different protection states, file usage &
commitment control
– Gives great deal of flexibility for jobs above MI
ILE
Concepts
Benefits (contd...)
– Better environment for ‘C’
– Foundation for the future
ILE
Binding