Ile Concepts - Bin.pptx

  • Uploaded by: Binay
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Ile Concepts - Bin.pptx as PDF for free.

More details

  • Words: 5,931
  • Pages: 150
Why a New RPG 

Ready for future enhancements and growth



Expand or eliminate language limits



Fulfill RPG programmer’s requirements



­

Longer field names

­

Free form expressions

­

Date/time support

Modernize through evolution

Why ILE 

Improve Modularity



Productivity



Mixed language support



Better runtime control (activation groups)



Foundation for the future

ILE Concepts 



New set of tools and associated system support designed to enhance program development on the AS/400 system. Benefits – – – – – – – –

Binding Modularity Reusable component Common run time services Co- existence Better control over resources Better control over language interactions Better code optimization

ILE Concepts 

Benefits

(contd...)

– Better environment for ‘C’ – Foundation for the future

ILE Binding

Bind different modules to form a program  Modules can be of different languages 

ILE Integrated Language Environment

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 RPG Source statements RPG/400 Compiler Intermediate rep. of pgm Program resolution monitor Program template MI Instructions MI Boundary

Translator OPM

Program object (IMPI instructions)

ILE EPM (Extended Program Model)   





Extensions added to implement C/400 & PASCAL Did not replace OPM, but above OPM Support for Block Structure Languages – Block Structured Language are designed to enable modular style of programming – Series of small program blocks are linked together by CALL instructions EPM build without any changes to MI to support lot of CALLs Performance penalty when user started or called EPM programs

ILE EPM C/400 Source statements Compiler UCODE UCODE Optimizer IRP Code generator C/400 COMPILER

UCODE Intermediate rep. of pgm

ILE ILE (Integrated Language Environment)  

 



Introduced in 1993 for V2R3 An architectural enhancement to the MI & objects below MI Output of ILE translator is non-executable (Modules) ILE binder packages these modules into executable program New type of CALL was introduced called STATIC CALLS

ILE CALL Types 

Dynamic CALL – – – – –



All references are resolved at execution time by name This approach is called LATE BINDING Flexible Low performance Slow

Static CALL – – – – –

All references are resolved at compilation time This approach is called EARLY BINDING Non-Flexible High performance Faster

ILE Jargons 

Procedure – Sequence of source statements which can be called at any entry point with optional parameters



Module – Object that contains code produced by output of ILE Compiler – Non-Executable – Can contain one or more procedures – Can be from different languages (RPG/ CL/C /COBOL) – To produce programs & service programs

ILE Jargons 

Program – – – – –

Executable code made up of one or more modules Can be made up of modules of different languages Has a single entry point Called by Dynamic CALL One of the procedures is designated as Program Entry Point (PEP) – Programs can be called with a static call within the same program

ILE Jargons 

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 

Bound by Reference

(Contd...)

– Authority resolutions done at runtime – An additional overhead – During execution, performance is about the same as that of bound by Copy

ILE Process Management 

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

Types of storage area :  PSSA – Program Static Storage Area – Single copy of static storage area existed for the entire process 

PASA – Program Automatic storage area – This area in the process object contained the call and return task – IWA - Invocation work area



Heap Storage – Not supported by OPM – To be managed outside the module separated by each language compiler

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 



New set of tools and associated system support designed to enhance program development on the AS/400 system. Benefits – – – – – – – –

Binding Modularity Reusable component Common run time services Co- existence Better control over resources Better control over language interactions Better code optimization

ILE Concepts 

Benefits

(contd...)

– Better environment for ‘C’ – Foundation for the future

RPG IV and ILE 

RPG IV - a better RPG



ILE - a better runtime environment



Can use RPG IV WITHOUT ILE

Scoop Of Class



RPG IV features and functions



Basic ILE features that enhance use of RPG IV

Readability Enhancements 

MIXed case translated to upper case by compiler FieldA = FIELDA = fielda



10 character names Full DDS name OK Often 14 columns to allow for array indexing AFieldName AnArray(indx)



Under_score allowed except as first character



Completely blank lines allowed - can split code logically

New Limits ! Description Field/array name Data structure name Format name File name Number of files Character field Constant Named data structure Unnamed data structure Numberof decimal places Array elements Number of arrays Number od subroutines Size of program

RPG III 6 6 8 8 50 256 256 9,999 9,999 9 9,999 200 256 Varies

RPG IV 10 10 10 10 No limit 32,767 1,024 32,767 9,999,999 30 32,767 No limit No limit No limit

Other Changes 

Keyword orientation on specs -

Similar to DDS coding Used on H, F, D specs Enhances readability for seldom used features

-

Allows for flexibility for future growth



Comments in col. 81 - 100



New source member type - RPGLE - PDM/SEU support - SEU “windows” to column 6

Other Changes 



More flexible format -

Keywords not column oriented

-

Keyword areas can be continued

-

C spec extended factor 2

Use of : and ( ) as separators

RPG IV Conversion Aid 

CVTRPGSRC takes RPG/400 to RPG IV format



No re-engineering



Source member larger by 25 %



Manual intervention may be required

Report and Log Report 

Problems



Flags where manual intervention needed



Flags/COPY and CALLS for consideration



Pre-analysis

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 0000046 * RNM0511

C

CALL ‘DUMMY’ CALL operation code found

0000047 * RNM0517

C*

DEBUG DEBUG operation code not supported in RPG IV

0000048 * RNM0506

C

FREE ‘DUMMY’ FREE operation code is not supported in RPG IV.

0000052 * RNM0508

C/COPY RPGOLD,PAYTAX /COPY compiler directive found

Converting Copy Books 

May need to move source from one spec to another (I to D)



Copy books may be invalid “as-is”



Can convert Copy Books separately - EXPCPY(*NO)



Can include into source - EXPCPY(*YES)

Conversion Command

ILE Binding

Bind different modules to form a program  Modules can be of different languages 

Specifications Main Source Section Specifications H - Control(Header) Specification F - File Description Specification D - Definition Specification I - Input Specification C - Calculation Specification O - Output Specification Subprocedure Specifications P D C -

Procedure Specification Definition Specification 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 III Position 15 18 19 20 21 26 41 43 57 75-80 New New

Meaning RPG IV Keyword Dump Statements executed DEBUG Currency symbol CURSYM UDATE Format DATEDIT UDATE Edit DATEDIT Decimal notation DECEDIT Alt. Collating Seq. Table ALTSEQ Forms Alignment FORMSALIGN File translation FTRANS Transparency check (graphics) Not required Prog. Or module ID DFTNAME Default Date data type format DATFMT Default Time data type format TIMFMT

F-Specs 

File Description + File Continuation + Line Counter



File name of 10 characters



Record length of 5 digits



Relaxed FD checks! -



File can be defined I/O but used as input-only

Keyword based continuation area similar to DDS

F-Specs RPG III

RPG IV

F-Spec Example



F-Spec continuation not required

F-Spec Keywords 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

K e y w o rd{(va lu e )} E x p la in atio n C O M M IT {(rp g _ n a m e ) C o n d itio n a lco m m itm e n tco n tro l-o p tion a lp a ra m e te r IN C L U D E (fm t_ n a m e {:fm t_ n a m e … }) O p p o siteo fIG N O R E P R E F IX (p re fix _n a m e {:n b r_ ch r_ re p l})A tta tch e sp refixton a m e so fa llfie ld s ina llre co rd sofafile D A T F M T (fo rm a t{sep e ra to r}) D e fa u ltD a tefo rm a t+se p ara to r(o p t.) T IM F M T (fo rm a t{se p a ra to r}) D e fa u ltT im efo rm a t+se p ara to r(o p t.)

Current RPG/400

New RPG IV

I-Spec Changes 10

Character File and Record names

14

Character space for field names

2

Character space for field names

Data Structures and named constants on D-spec

New D Specification 

Includes Data Structures from I-Spec, Arrays from E-Spec



Additional facilities Standalone fields Arrays within structures Arrays & data structures based on pointers



Can indent field name to show structure



More readable and consistent



Easier to add function

New D-Spec for Data Definition

   

     

Name - Name of data item (field, constant, datastructure, DS subfield) E - Indicates external DS T - Type of DS: (S - Program Status, U - Data area Ds - Type of field or DS indication DS - Data structure C - Constant S - Defines standalone field or array Blank - DS subfield From - From position To/L - To position or length I - Internal data type Dc - Decimal positions Keywords - Functions using keywords (similar to DDS) Keywords-cont - If pos. 7-43 blank, continued from previous D-Spec

D-Spec : Example

D-Spec : Data Structures K ey w o rd IN Z (con stant) O C C U R S (nu m ber) O V E R LA Y (n am e:{p os}) E X T N A M E (n am e{:fm t_n am e}) E X T F LD (fldn am e) P R E F IX (prefix_n am e)

D escrip tio n In itializetovalueofconstant #occu ran cesinm ultip leoccu ran ceD S R ed efinessub field sinaD S F ilen am eforextern allyd escribedD S E xternam fieldnam eb ein gren am ed P refixsu b field sfrom extern allyd efinedD S

Data Structure : Example

Absolute vs. Length Notation

Can also be written :

Defining Standalone Fields    

Rather than C-Spec Use S in Ds column Length only (no absolute) Can be an array

Defining Named Constants    

Use C in the Ds column No length Value specified in Keywords area Terminates any previous DS

D-Spec Keywords for Arrays Keyword DIM(number) ASCEND/DESCEND PERRCD(number) FROMFILE/TOFILE EXFMT ALT(array_name) CTDATA

Description Number of elements in array Order of elements in array # elements for compile time table/array From/To file for prerun time array/table External data type for compile and pre-run time array Compile/preruntime array alternating format Indicates

Defining Arrays in Data Structures

LIKE 

Rather than DEFINE Opcode (DEFN)



LIKE - length, decimal positions and data type copied



Adjust length via + or -



Use with fields, subfields, arrays

Defining Date, Time and Timestamp Fields 

Define on D or I



Can externally define in DDS or SQL



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 Name Description Format SepLength Example *MDY Month/Day/Year mm/dd/yy /-*,& 8 01/15/99 *DMY Day/Month/Year dd/mm/yy /-*,& 8 15/01/99 *YMD Year/Month/Day yy/mm/dd /-*,& 8 99/01/15 *CYMDCenturyYear/Month/Day cyy/mm/dd /-*,& 9 199/01/15 *JUL Julian yy/ddd /-*,& 6 99/015 *ISO Intl. Stds. Org yyyy-mm-dd - 10 1999-01-15 *USA IBMUSAStd. mm/dd/yyyy / 10 01/15/1999 *EUR IBMEuropeanStd. dd.mm.yyyy * 10 15.01.1999 *JIS JapaneseInd. Std. yyyy-mm-dd - 10 1999-01-15

Time Formats

NameDescription Format SepLength Example *HMSHours:Minutes:Secondshh:mm:ss :.,& 8 13:00:00 *ISOIntl.Stds.Org. hh.mm.ss . 8 13.00.00 *USAIBMUSAStd. hh:mmAM : 8 01:00PM *EURIBMEuropeanStd. hh.mm.ss . 8 13.00.00 *JIS JapaneseInd.Std. hh:mm:ss : 8 13:00:00

Date & Time Formats : Example

DateFld = 04/15/99 TimeFld = 13:00:00

C-Spec Changes 14

Factor 1, Factor 1, Result field characters

5

digits for field length

2

digits for decimal places

10

character opcode space - ‘stretched’ Opcodes - Optional extenders

Only ONE conditioning indicator

Renamed Opcodes O ld B IT O F C H E K R C O M IT D E F N D E L E T E X C P T L O K U P O C U R R E D P E R E T R N S E L E C S E T O F U P D A T U N L C K W H xx

N e w B IT O F F C H E C K R C O M M IT D E F IN E D E L E T E E X C E P T L O O U P O C C U R R E A D P E R E T U R N S E L E C T S E T O F F U P D A T E U N L O C K W H E N xx

C-Spec : Other Op Codes

New

ADDDUR

add duration

EXTRCT

extract date/time

SUBDUR

subtract duration

TEST

test valid date/time

EVAL

evaluate expression

CALLB

call a bound procedure

DOW

do while

DOU

do until

WHEN

when true then select

IF

conditional if

C-Spec : Other Op Codes

Changed CLEAR RESET

clear structure/variable/format 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 C DOU (Counter>maximum) OR (*IN98=‘1’) Arithmetic C EVAL Counter= Counter+1 String C EVAL Phone=‘(‘+AreaCode+‘)’+Exchange+‘-’+ PhoneNo

Why Use Expressions - RPG/400 RPG/400 Weekly Style Payroll:

  

Not easily read Must use temporary fields Half adjustment

Why Use Expressions - RPG IV RPG IV Weekly Style Payroll:

  

Easier to read, understand and maintain No Temporary result fields Half adjust final result only (better accuracy)

Precedence Rules 1. ( ) 2. Built in Functions 3. Negation (-, NOT) 4. ** Exponentiation 5. * ,/ Multiplication and division 6. +, - Addition and subtraction 7. =, > =, >, < =, <, < > Comparison 8. AND 9. OR 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 (H) (N) (P)

Half adjust Record read without lock Pad result field with blanks

(D)

Date field identification

(T)

Time field identification

(Z)

Timestamp field identification

Place to right of Opcode in parenthesis EVAL(H) is the same as EVAL (H)

C-Spec : CLEAR and RESET

O-Spec Changes 10

Character File O format names

10

Character EXCEPT label

14

Character space for output field name Room for indexes

3

Positions for space before/after

3

Positions for skip before/after

What can be done?       

Define on D_spec as D(date), T(Time), Z (timestamp) Specify format (*MDY, *YMD, *JUL) Calculate durations (e.g. days between dates) Extract components (e.g. year from date) Move data (e.g. move numeric field to date) Compare values (e.g. Date1 > Date2) Test values (does Field1 contain valid MDY format?)

Date and Time Durations *YEARS *MONTHS *DAYS *HOURS *MINUTES *SECONDS *MSECONDS

OR

*Y *M *D *H *MN *S *MS



Specify as subfactor in factor 2 or result field



Used with ADDSUR or SUBDUR

ADDDUR   

Add days, months, or years to a date field Add hours, minutes, seconds to a time field Add all of the above and microseconds to timestamp field

SUBDUR  

-

Subtract duration from date, time or timestamp Calculate duration between: two dates, time or timestamps date and timestamp time and timestamp

Extracting Date and Time EXTRCT operation code extracts portions of fields •

Year, month, day part of date or timestamp fields



Hours, minutes, seconds part of time or timestamp



Microseconds part of timestamp

Moving Data 

MOVE and MOVEL



Like to like with format conversion - Data to Date, Time to Time, Timestamp to Time stamp - Date or Time to Time stamp - Timestamp to Date or Time

 

Date or Time to Character or Numeric - Separators removed on move to numeric Character or numeric to Date, Time or Timestamp - Valid separators required for character fields

Moving to/from Date and Time Fields

Using Date Constants

Comparing Dates and Times 

Greater than means later than



Less than means before

Testing for Valid Dates

Advanced Functions in RPG IV 

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



Sharing data items between bound modules

% TRIM Built-in Function %TRIM(string) %TRIML(string) %TRIMR(string) - %TRIM strips leading and trailing blanks from character or graphic fields - %TRIML strips leading blanks only - %TRIMR strips trailing blanks only

%SUBST Built-in Function %SUBST(string:start{length})

%SIZE Built-in Function %SIZE(name{:*ALL}) Returns storage size (in bytes) occupied by the named item

%ELEM Built-in Function %ELEM(name) Returns number of elements in an array, table or multi-occurrence data structure

Using Built-ins, LIKE, OVERLAY, code can be made to be more “self maintaining”

If CustName is externally described, what happens when length changes?

Modular Programming • Developing modular code means - Better chance for proven code reuse - More options for workload distribution - Faster compile times for smaller code modules - Ability to purchase commercially available routines • With AS/400’s dynamic program call, it sometimes means: - Relatively slow performance - Performance “hot spots” for frequently called routines • Integrated Language Environment brings static binding - Reduces call performance overhead for frequently called routines - Enables more modular application design

Creating RPG IV Programs ILE programs may contain 1 or more modules For single module programs : CRTBNDRPG

RPG Source Mbr X

CRTBNDRPG

*MODULE X

*PGM X

Procedure X

Procedure X

Creating RPG IV Programs ILE program may contain 1 or more modules For multiple module programs: CRTRPGMOD + CRTPGM *MODULE A

RPG Src Mbr A

CRTRPGMOD

Proc. A *PGM A *MODULE B

RPG Src Mbr B

CRTRPGMOD

Proc. B

MOD( A B C) *MODULE C

RPG Src Mbr C

CRTPGM…

CRTRPGMOD

Proc. C

Proc A

Proc B

Proc C

ILE RPG/400 Module * MODULE Main Procedure H F D I C O

Program Data

ILE RPG/400 Module with Subprocedures * MODULE Main Source Section

Main Procedure H F D I C O

Global Subprocedure 1

P D C P

Local

Subprocedure 2

Part of Main Source Section

P D C P

Local Program Data

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 CALLB must target a bound procedure - Takes advantage of static binding prior to run time - Procedure is code included in a *MODULE - *Module with called procedure must have been found during CRTPGM step CALLB is faster than CALL

CALL Program vs. CALLB Procedure *PGM X CALL Y

*PGM Y CALL A

*PGM A Procedure Procedure Procedure C A B 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

RPG Src Mbr A

CRTRPGMOD

Proc. A *PGM A *MODULE B

CBL Src Mbr B

CRTRPGMOD

Proc. B

MOD( A B C) *MODULE C

CL Src Mbr C

CRTPGM…

CRTRPGMOD

Proc. C

Proc A

Proc B

Proc C

Service Programs  Problems with Bind by Copy Multiple copies of frequently used routines More complicated to update for maintenance  Solution : Service Programs Similar to a subroutine library Single copy of frequently -used routines Call performance similar to bind by copy

Creating Service Programs *MODULE X

RPG Src Mbr A

CRTRPGMOD

Proc. X *SRVPGM J *MODULE Y

RPG Src Mbr B

CRTRPGMOD

Proc. Y

MOD( X Y C) *MODULE C

RPG Src Mbr C

CRTSRVPGM J…

CRTRPGMOD

Proc. C

Proc X

Proc Y

Proc C

Using Service Programs Bind by Copy and Bind by Reference can be used in same program Completion of bind between Program A and Service Program J occurs at Call time of Program A *SRVPGM J

*PGM A Procedure A CALL B

Procedure B CALL C

Procedure X

Procedure D

Procedure Y Procedure C

Bind by Copy

*PGM D

Bind by Reference

CALL C

Bind by Copy and Reference  Both use faster CALLB operation code  Bind by Copy - Better suited for modules not likely to be reused in other programs - Slightly better run time performance since no startup for *SRVPGM  Bind by Reference - Better suited for modules to be reused in many programs - Convenient packaging for buying or selling routines

Coding for Performance Good performance coding techniques still apply, e.g.: - Shared open data paths for commonly used files - Leave LR off in commonly called procedures Even more important in more modular applications Only CALL time performance is improved with static binding - Not opening/closing of database files - Not storage initialization

Prototyping - Parameters - Type of Call - Written by developer of subprocedure - /COPY by Caller of subprocedure

Components of Subprocedure · P-Spec - MAIN or NOMAIN - EXPORT · D-Spec - Local Scope Variables · C-Spec - Logic - Return information to CALLER

Prototyped CALL · MUST be used to Call Subprocedures 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 - Each CALLP adds to stack - New storage for all data items - Data unique for each invocation

CRTPGM Command

CRTPGM Command….contd....

Source View Debugger New OS/400 debugger for ILE programs View source on screen in debug mode - Set breakpoints by cursor position - Step through source statements - Display / change values of programs

Maintaining ILE Programs • Make source changes • CRTRPGMOD to recreate the module • Either : - Rebind with CRTPGM specifying all modules/service programs needed - UPDPGM to replace the affected module • Repeat previous step for any other programs containing the changed module

Sharing Data in ILE Programs 

Modules bound together may share data items

- One module defines and exports data - One or more modules bound to the “exporter” may import the data 

An alternative to other methods of sharing data

- More convenient than passing parameters - Safer than using LDA

IMPORT/EXPORT Keywords 

Shared data defined on the D spec with keywords - EXPORT: Allows data to be used by another module - IMPORT: This data is stored in the “exporter” module

 

Allowed for data structures and standalone fields/arrays Exported data initialized ONLY when *PGM containing module is called - Not re-initialized after LR in the exporting module



Multiple modules may IMPORT a specific data item



Only one module may EXPORT a specific data item

IMPORT/EXPORT Example Module A D ShardArray

S

5

DIM(10) EXPORT

S

5

DIM(10) IMPORT

Module D D ShardArray 

Procedure A issues CALLB to Procedure B



Procedure B issues CALLB to Procedure C



Procedure C issues CALLB to Procedure D

Procedure D now “sees” and can update data in ShardArray

Activation Groups 

ILE programs can run in default or specific ILE Activation Group



Activation groups isolate applications



ILE AGs have benefits versus default: -

Protect shared resources Control of scoping of file overrides

-

Control of scoping of commitment control Easy cleanup

Activation Group Example JOB Default Activation Group

Activation Group: ORDENTRY PGM 1

PGM A

PGM B

PGM 3 A

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 Instructions

program instructions

JOB

JOB

Activation Group Program A

Activation Group Program A

Variable X = 10

Variable X = 20

One copy of static variables for each program activation

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

Activation Group Usage : Example JOB Activation Group

Activation Group

RPG Order Entry Application from Vendor 1

RPG Accounts Payable Application from Vendor 2

Activation Group COBOL Inventory Control Application from Vendor 3

Activation Group C Decision Support Application from Vendor 4

Activation Groups and Conversion



Run time behaviors different depending on whether ILE or default AG used



Run complete application in one or other - 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 RPG Source statements RPG/400 Compiler Intermediate rep. of pgm Program resolution monitor Program template MI Instructions MI Boundary

Translator OPM

Program object (IMPI instructions)

ILE EPM (Extended Program Model)   





Extensions added to implement C/400 & PASCAL Did not replace OPM, but above OPM Support for Block Structure Languages – Block Structured Language are designed to enable modular style of programming – Series of small program blocks are linked together by CALL instructions EPM build without any changes to MI to support lot of CALLs Performance penalty when user started or called EPM programs

ILE EPM C/400 Source statements Compiler UCODE UCODE Optimizer IRP Code generator C/400 COMPILER

UCODE Intermediate rep. of pgm

ILE ILE (Integrated Language Environment)  

 



Introduced in 1993 for V2R3 An architectural enhancement to the MI & objects below MI Output of ILE translator is non-executable (Modules) ILE binder packages these modules into executable program New type of CALL was introduced called STATIC CALLS

ILE CALL Types 

Dynamic CALL – – – – –



All references are resolved at execution time by name This approach is called LATE BINDING Flexible Low performance Slow

Static CALL – – – – –

All references are resolved at compilation time This approach is called EARLY BINDING Non-Flexible High performance Faster

ILE Jargons 

Procedure – Sequence of source statements which can be called at any entry point with optional parameters



Module – Object that contains code produced by output of ILE Compiler – Non-Executable – Can contain one or more procedures – Can be from different languages (RPG/ CL/C /COBOL) – To produce programs & service programs

ILE Jargons 

Program – – – – –

Executable code made up of one or more modules Can be made up of modules of different languages Has a single entry point Called by Dynamic CALL One of the procedures is designated as Program Entry Point (PEP) – Programs can be called with a static call within the same program

ILE Jargons 

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 

Bound by Reference

(Contd...)

– Authority resolutions done at runtime – An additional overhead – During execution, performance is about the same as that of bound by Copy

ILE Process Management 

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

Types of storage area :  PSSA – Program Static Storage Area – Single copy of static storage area existed for the entire process 

PASA – Program Automatic storage area – This area in the process object contained the call and return task – IWA - Invocation work area



Heap Storage – Not supported by OPM – To be managed outside the module separated by each language compiler

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 



New set of tools and associated system support designed to enhance program development on the AS/400 system. Benefits – – – – – – – –

Binding Modularity Reusable component Common run time services Co- existence Better control over resources Better control over language interactions Better code optimization

ILE Concepts 

Benefits

(contd...)

– Better environment for ‘C’ – Foundation for the future

ILE Binding

Bind different modules to form a program  Modules can be of different languages 

Related Documents

Ile[1]
November 2019 19
Concepts
October 2019 52
Concepts
November 2019 47
Concepts[
October 2019 46
Concepts
November 2019 37

More Documents from ""