So, I found some more old RPG documents, and decided to publish on the blog rather than leave in the dusty corners of my hard drive. Perhaps they will be of interest to somebody out there?
Advantages of ILE:
RPG IV is more readable than older column based RPG400 and RPG3
Allows for greater application modularity with static binding which means there are fewer external calls.
Enhances programmer productivity by allowing greater code re use
Enhances mixed language support by allowing the binding ILE languages into a single program
Builds a foundation for the future by moving closer to object oriented design , modular programming and code reuse
Enhancements in RPGIV
- Mixed Case entry permitted
- Compiler is not case sensitive
- Compiler can translate mixed case to upper case.
- Character names allowed
- Full DDS length supported
- Columns available for suscripts
- Undescore allowed in names
- Blank lines allowed making it more readable
Limit changes :
Limit Changes | RPGIII | RPGIV |
Field names & Array Names | 6 | 10 |
Length of Character Variable | 256 | 32767 |
No of Possible array elements | 9999 | 32767 |
No of Possible Subroutines | 256 | No Limit |
No of Decimal Positions | 9 | 30 |
No of files per program | 50 | No Limit |
H spec :
- Completely free format
- Additional functions: Date and Time Format
- Enhanced Readability
F-Spec:
- Part of F-spec are now keyword based
- No of files un limited
- File definition checks have been relaxed
- File names length increased to 10 characters and record lengths to 5 digits
D-Spec:
- Defining the data structures
- Defining arrays
- Defining standalone fields
- Indent field names to show structures
- Easily define arrays within data structures
- Use keywords to make your code more readable and more flexible
Keywords used in the Define Specification:
INZ
OCCURS
OVERLAY
EXTNAME
EXTFLD
PREFIX
DIM
ASCEND/DESCEND
PERRCD
FROMFILE/TOFILE
EXFMT
ALT
CTDATA
Keywords used in the Calculation Specification:
RPGIII | RPGIV |
BITOF | BITOFF |
CHEKR | CHECKR |
COMIT | COMMIT |
DEFN | DEFINE |
DELET | DELETE |
EXCPT | EXCEPT |
LOKUP | LOOKUP |
OCCUR | OCCUR |
REDPE | READPE |
RETRN | RETURN |
SELEC | SELECT |
SETOF | SETOFF |
UPDAT | UPDATE |
UNLCK | UNLOCK |
WHXX | WHENXX |
- Factor1,Factor2 & Result each increased to 14 characters
- Extended Factor2 allows free-format expressions
- Field length increased to 5 positions
- Decimal Positions increased to 2.
- Many opcodes increased to 6 characters
- Space for opcodes plus extenders increased to 10 characters
- New opcodes and operators added with extended factor 2
- Conditioning indicators reduced to 1 from 3
Keywords used in the OUTPUT Specification:
- No major changes in the O specification
- Names on the O spec have been expanded
- Skip Before/After and Space Before/After have also been extended , to allow 3 positions
New Opcodes:
- ADDDUR
- CALLB
- CALLP
- DOU
- DOW
- EVAL
- EXTRCT
- IF
- SUBDUR
- TEST
- WHEN
RPGIV supports date,time and timestamp data types With date , time and timestamp fields you can Calculate durations
Extract portions of dates and times
- Move data from one field to another
- Compare their values
- Test for valid values
The data types supported are
- D for Date
- T for Time
- Z for Timestamp
The internal format can be specified on the H spec for all fields or on the D spec for specific fields
With the introduction of the ADDDUR & SUBDUR opcodes you can easily add or subtract duration b/n date,time or timestamp fields.
The EXTRCT opcode easily extracts a logical portion of a date ,time or timestamp field.
The MOVE or MOVEL opcode can be used to easily move data to and from date,time & timestamp fields.
You can compare dates, times& timestamps & test the validity of these fields using the TEST opcode.
EXPRESSIONS:
More precise results using expressions
RPGIV is easier to read and maintain as it handles half adjustments & avoids usage of temporary variables
Three type of expressions :Arithmetical, conditional and string
Expressions are entered in the Extended calculation.
Precedence rules apply to the evaluation of expressions.
Expressions use DOU,DOW,IF,WHEN&EVAL opcodes.
SUBPROCEDURES & PROTOTYPES:
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 subporocedures 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.
You can call subprocedures recursively.
Advanced Functions in RPGIV:
RPGIV provides you with many advanced functions that make your code easier to maintain . It Provides you with powerful built-in functions that allows you to code more powerful and self-maintaining applications.
TRIM BIF allows you to trim spaces from the beginning or end of a character variable.
SUBST allows you to take a substring of a field.
SIZE allows you to dynamically determine in size of a field,array or data structure.
ELEM returns the number of elements in an array,table or multi-occurance data structure.
Based variables with pointers allow you to access information stored inside or outside your program.
Modules can be bound together and data can be shared across modules using the IMPORT and EXPORT keywords .
Using ILE allows you to take advantage or modular programming :
ILE enables modular programming through seperately compiled pieces of code called modules.
These modules are statistically bound. They are created using CRTxxxMOD command.
OPM program runs in the default activation group . You can create an RPGIV program that is OPM compatible by using CRTBNDRPG with DFTACTGRP(*YES)
There are two ways to create an ILE program.you can create bound RPG program using CRTBNDRPG Command or create a program binding modules together.
You can create a service program to handle frequently used routines & for better performance.
Built-in-Functions:
%ADDR
%ELEM
%PADDR
%SIZE
%SUBST
%TRIM
%TRIML
%TRIMR
Built-in Functions enables to :
- Trim spaces from character fields
- Refer to substring of a field
- Return the size of a field
- Return the number of elements in an array or multi-occurance data structure.
- Place the address of an item in a pointer
- Place the address of a procedure in a pointer variable
Other advance functions include:
Pointers to base storage inside or outside your program
Data items using keywords that can be shared between bound modules.
Activation group:
An Activation group is a substructure of a job. It consists of system resources allocated to one or more programs running in it. It is a type of firewall that you can build around your application to protect its resources.
ILE activation groups have many benefits over the default activation group:
- Protection of shared resources from other 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.
- Easily cleanup of 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.