What's New in V5R2?

The following list describes the enhancements made to ILE RPG in V5R2:
  • Conversion from character to numeric

    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.

  • Bitwise logical built-in functions

    %BITAND, %BITOR, %BITXOR and %BITNOT allow direct bit manipulation within RPG expressions.

  • Complex data structures
    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.
  • Enhanced externally-described data structures

    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.

  • Enhancments to keyed I/O
    Programmers can specify search arguments in keyed Input/Output operations in /FREE calculations in two new ways:
    1. By specifying the search arguments (which can be expressions) in a list.
    2. By specifying a data structure which contains the search arguments.
    Examples: D custkeyDS    e ds        extname(custfile:*key)
               /free
                  CHAIN  (keyA : keyB : key3) custrec;
                  CHAIN  %KDS(custkeyDS) custrec;
  • Data-structure result for externally-described files

    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.

  • UPDATE operation to update only selected fields

    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).

  • 31 digit support

    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.

  • Performance option for FEOD

    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.

  • Enhanced data area access

    The DTAARA keyword is enhanced to allow the name and library of the data area to be determined at runtime

  • New assignment operators
    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.
  • IFS source files

    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.

  • Program Call Markup Language (PCML) generation

    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).

Table 1. Changed Language Elements Since V5R1
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.
EXTNAME(filename{:extrecname}
{:*ALL|*INPUT|*OUTPUT|*KEY}
)
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, DELETE, READE, 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.
Table 2. New Language Elements Since V5R1
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
LIKEREC(intrecname{:*ALL|
*INPUT|*OUTPUT|*KEY})
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.