The following list describes the enhancements made to ILE RPG in V5R2:
Built-in functions %DEC, %DECH, %INT, %INTH, %UNS, %UNSH and %FLOAT are enhanced to allow character parameters. For example, %DEC('-12345.67' : 7 : 2) returns the numeric value -12345.67.
%BITAND, %BITOR, %BITXOR and %BITNOT allow direct bit manipulation within RPG expressions.
Data structure definition is enhanced to allow arrays of data structures and subfields of data structures defined with LIKEDS that are themselves data structures. This allows the coding of complex structures such as arrays of arrays, or arrays of structures containing subarrays of structures.
Example: family(f).child(i).hobbyInfo.pets(p).type = 'dog';
family(f).child(i).hobbyInfo.pets(p).name = 'Spot';
In addition, data structures can be defined the same as a record format, using the new LIKEREC keyword.
Externally-described data structures can hold the programmer's choice of input, output, both, key or all fields. Currently, externally-described data structures can only hold input fields.
Programmers can specify search arguments in keyed Input/Output operations in /FREE calculations in two new ways:
Examples: D custkeyDS e ds extname(custfile:*key)
/free
CHAIN (keyA : keyB : key3) custrec;
CHAIN %KDS(custkeyDS) custrec;
A data structure can be specified in the result field when using I/O operations for externally-described files. This was available only for program-described files prior to V5R2. Using a data structure can improve performance if there are many fields in the file.
A list of fields to be updated can be specified with an UPDATE operation. Tthis could only be done by using exception output prior to V5R2.
Example: update record %fields(salary:status).
Supports packed and zoned numeric data with up to 31 digits and decimal places. This is the maximum length supported by DDS. Only 30 digits and decimal places were supported prior to V5R2.
The FEOD operation is enhanced by supporting an extender N which indicates that the operation should simply write out the blocked buffers locally, without forcing a costly write to disk.
The DTAARA keyword is enhanced to allow the name and library of the data area to be determined at runtime
The new assignment operators +=, -=, *=, /=, **= allow a variable to be modified based on its old value in a more concise manner.
Example: totals(current_customer) += count;
This statement adds "count" to the value currently in "totals(current_customer)" without having to code "totals(current_customer)" twice.
The ILE RPG compiler can compile both main source files and /COPY files from the IFS. The /COPY and /INCLUDE directives are enhanced to support IFS file names.
The ILE RPG compiler will generate an IFS file containing the PCML, representing the parameters to the program (CRTBNDRPG) or to the exported procedures (CRTRPGMOD).
Language Unit | Element | Description |
---|---|---|
Built-in functions | %DEC(expression) | Can now take parameters of type character. |
%DECH(expression) | ||
%FLOAT(expression) | ||
%INT(expression) | ||
%INTH(expression) | ||
%UNS(expression) | ||
%UNSH(expression) | ||
Definition specification keywords | DTAARA({*VAR:}data-area-name) | The data area name can be a name, a character literal specifying 'LIBRARY/NAME' or a character variable which will determine the actual data area at runtime. |
DIM | Allowed for data structure specifications. | |
LIKEDS | Allowed for subfield specifications. | |
) | The optional "type" parameter controls which type of field is extracted for the externally-described data structure. | |
Definition Specifications | Length and decimal place entries | The length and number of decimal places can be 31 for packed and zoned fields. |
Operation codes | CHAIN, DELETEREADE, READPE, SETGT, SETLL | In free-form operations, Factor 1 can be a list of key values. |
CHAIN, READ, READC, READE, READP, READPE, UPDATE, WRITE | When used with externally-described files or record formats, a data structure may be specified in the result field. | |
UPDATE | In free-form calculations, the final argument can contain a list of the fields to be updated. | |
FEOD | Operation extender N is allowed. This indicates that the unwritten buffers must be made available to the database, but not necessarily be written to disk. | |
Calculation specifications | Length and decimal place entries | The length and number of decimal places can be 31 for packed and zoned fields. |
Language Unit | Element | Description |
---|---|---|
Expressions | Assignment Operators += -= *= /= **= | When these assignment operators are used, the target of the operation is also the first operand of the operation. |
Control Specification Keywords | DECPREC(30|31) | Controls the precision of decimal intermediate values for presentation, for example, for %EDITC and %EDITW |
Definition specification keywords | Defines a data structure whose subfields are the same as a record format. | |
Built-in functions | %BITAND(expression : expression) | Returns a result whose bits are on if the corresponding bits of the operands are both on. |
%BITNOT(expression) | Returns a result whose bits are the inverse of the bits in the argument. | |
%BITOR(expression : expression) | Returns a result whose bits are on if either of the corresponding bits of the operands is on. | |
%BITXOR(expression : expression) | Returns a result whose bits are on if exactly one of the corresponding bits of the operands is on. | |
%FIELDS(name{:name...}) | Used in free-form "UPDATE to specify the fields to be updated. | |
%KDS(data structure) | Used in free-form keyed operation codes CHAIN, SETLL, SETGT, READE and READPE, to indicate that the keys for the operation are in the data structure. |