What's New in V5R1?

The ILE RPG compiler is part of the IBM® Rational® Development Studio for i product, which now includes the C/C++ and COBOL compilers, and the Application Development ToolSet tools.

The major enhancements to RPG IV since V4R4 are easier interfacing with Java™, new built-in functions, free form calculation specifications, control of which file is opened, qualified subfield names, and enhanced error handling.

The following list describes these enhancements:

  • Improved support for calls between Java and ILE RPG using the Java Native Interface (JNI):
    • A new data type: Object
    • A new definition specification keyword: CLASS
    • The LIKE definition specification keyword has been extended to support objects.
    • The EXTPROC definition specification keyword has been extended to support Java procedures.
    • New status codes.
  • New built-in functions:
    • Functions for converting a number into a duration that can be used in arithmetic expressions: %MSECONDS, %SECONDS, %MINUTES, %HOURS, %DAYS, %MONTHS, and %YEARS.
    • The %DIFF function, for subtracting one date, time, or timestamp value from another.
    • Functions for converting a character string (or date or timestamp) into a date, time, or timestamp: %DATE, %TIME, and %TIMESTAMP.
    • The %SUBDT function, for extracting a subset of a date, time, or timestamp.
    • Functions for allocating or reallocating storage: %ALLOC and %REALLOC.
    • Functions for finding an element in an array: %LOOKUP, %LOOKUPGT, %LOOKUPGE, %LOOKUPLT, and %LOOKUPLE.
    • Functions for finding an element in a table: %TLOOKUP, %TLOOKUPGT, %TLOOKUPGE, %TLOOKUPLT, and %TLOOKUPLE.
    • Functions for verifying that a string contains only specified characters (or finding the first or last exception to this rule): %CHECK and %CHECKR
    • The %XLATE function, for translating a string based on a list of from-characters and to-characters.
    • The %OCCUR function, for getting or setting the current occurrence in a multiple-occurrence data structure.
    • The %SHTDN function, for determining if the operator has requested shutdown.
    • The %SQRT function, for calculating the square root of a number.
  • A new free-form syntax for calculation specifications. A block of free-form calculation specifcations is delimited by the compiler directives /FREE and /END-FREE.
    Note: These directives are no longer needed. See /FREE... /END-FREE.
  • You can specify the EXTFILE and EXTMBR keywords on the file specification to control which external file is used when a file is opened.
  • Support for qualified names in data structures:
    • A new definition specification keyword: QUALIFIED. This keyword specifies that subfield names will be qualified with the data structure name.
    • A new definition specification keyword: LIKEDS. This keyword specifies that subfields are replicated from another data structure. The subfield names will be qualified with the new data structure name. LIKEDS is allowed for prototyped parameters; it allows the parameter's subfields to be used directly in the called procedure.
    • The INZ definition specification keyword has been extended to allow a data structure to be initialized based on its parent data structure.
  • Enhanced error handling:
    • Three new operation codes (MONITOR, ON-ERROR, and ENDMON) allow you to define a group of operations with conditional error handling based on the status code.

Other enhancements have been made to this release as well. These include:

  • You can specify parentheses on a procedure call that has no parameters.
  • You can specify that a procedure uses ILE C or ILE CL calling conventions, on the EXTPROC definition specification keyword.
  • The following /DEFINE names are predefined: *VnRnMn, *ILERPG, *CRTBNDRPG, and *CRTRPGMOD.
  • The search string in a %SCAN operation can now be longer than string being searched. (The string will not be found, but this will no longer generate an error condition.)
  • The parameter to the DIM, OCCURS, and PERRCD keywords no longer needs to be previously defined.
  • The %PADDR built-in function can now take either a prototype name or an entry point name as its argument.
  • A new operation code, ELSEIF, combines the ELSE and IF operation codes without requiring an additional ENDIF.
  • The DUMP operation code now supports the A extender, which means that a dump is always produced - even if DEBUG(*NO) was specified.
  • A new directive, /INCLUDE, is equivalent to /COPY except that /INCLUDE is not expanded by the SQL preprocessor. Included files cannot contain embedded SQL or host variables.
  • The OFLIND file-specification keyword can now take any indicator, including a named indicator, as an argument.
  • The LICOPT (licensed internal code options) keyword is now available on the CRTRPGMOD and CRTBNDRPG commands.
  • The PREFIX file description keyword can now take an uppercase character literal as an argument. The literal can end in a period, which allows the file to be used with qualified subfields.
  • The PREFIX definition specification keyword can also take an uppercase character literal as an argument. This literal cannot end in a period.

The following tables summarize the changed and new language elements, based on the part of the language affected.

Table 1. Changed Language Elements Since V4R4
Language Unit Element Description
Built-in functions %CHAR(expression{:format}) The optional second parameter specifies the desired format for a date, time, or timestamp. The result uses the format and separators of the specified format, not the format and separators of the input.
%PADDR(prototype-name) This function can now take either a prototype name or an entry point name as its argument.
Definition specification keywords EXTPROC(*JAVA:class-name:proc-name) Specifies that a Java method is called.
EXTPROC(*CL:proc-name) Specifies a procedure that uses ILE CL conventions for return values.
EXTPROC(*CWIDEN:proc-name) Specifies a procedure that uses ILE C conventions with parameter widening.
EXTPROC(*CNOWIDEN:proc-name) Specifies a procedure that uses ILE C conventions without parameter widening.
INZ(*LIKEDS) Specifies that a data structure defined with the LIKEDS keyword inherits the initialization from its parent data structure.
LIKE(object-name) Specifies that an object has the same class as another object.
PREFIX(character-literal{:number}) Prefixes the subfields with the specified character literal, optionally replacing the specified number of characters.
File specification keywords OFLIND(name) This keyword can now take any named indicator as a parameter.
PREFIX(character-literal{:number}) Prefixes the subfields with the specified character literal, optionally replacing the specified number of characters.
Operation codes DUMP (A) This operation code can now take the A extender, which causes a dump to be produced even if DEBUG(*NO) was specified.
Table 2. New Language Elements Since V4R4
Language Unit Element Description
Data types Object Used for Java objects
Compiler directives /FREE ... /END-FREE The /FREE... /END-FREE compiler directives denote a free-form calculation specifications block.
  /INCLUDE Equivalent to /COPY, except that it is not expanded by the SQL preprocessor. Can be used to inlcude nested files that are within the copied file. The copied file cannot have embedded SQlL or host variables.
Definition specification keywords CLASS(*JAVA:class-name) Specifies the class for an object.
LIKEDS(dsname) Specifies that a data structure, prototyped parameter, or return value inherits the subfields of another data strucutre.
QUALIFIED Specifies that the subfield names in a data structure are qualified with the data structure name.
File specification keywords EXTFILE(filename) Specifies which file is opened. The value can be a literal or a variable. The default file name is the name specified in position 7 of the file specification. The default library is *LIBL.
EXTMBR(membername) Specifies which member is opened. The value can be a literal or a variable. The default is *FIRST.
Built-in functions %ALLOC(num) Allocates the specified amount of storage.
%CHECK(comparator:base{:start}) Finds the first character in the base string that is not in the comparator.
%CHECKR(comparator:base{:start}) Finds the last character in the base string that is not in the comparator.
%DATE(expression{:date-format}) Converts the expression to a date.
%DAYS(num) Converts the number to a duration, in days.
%DIFF(op1:op2:unit) Calculates the difference (duration) between two date, time, or timestamp values in the specified units.
%HOURS(num) Converts the number to a duration, in hours.
%LOOKUPxx(arg:array{:startindex {:numelems}}) Finds the specified argument, or the specified type of near-match, in the specified array.
%MINUTES(num) Converts the number to a duration, in minutes.
%MONTHS(num) Converts the number to a duration, in months.
%MSECONDS(num) Converts the number to a duration, in microseconds.
%OCCUR(dsn-name) Sets or gets the current position of a multiple-occurrence data structure.
%REALLOC(pointer:number) Reallocates the specified amount of storage for the specified pointer.
%SECONDS(num) Converts the number to a duration, in seconds.
%SHTDN Checks if the system operator has requested shutdown.
%SQRT(numeric-expression) Calculates the square root of the specified number.
%SUBDT(value:unit) Extracts the specified portion of a date, time, or timestamp value.
%THIS Returns an Object value that contains a reference to the class instance on whose behalf the native method is being called.
%TIME(expression{:time-format}) Converts the expression to a time.
%TIMESTAMP(expression {:*ISO|*ISO0}) Converts the expression to a timestamp.
%TLOOKUP(arg:search-table {:alt-table}) Finds the specified argument, or the specified type of near-match, in the specified table.
%XLATE(from:to:string{:startpos}) Translates the specified string, based on the from-string and to-string.
  %YEARS(num) Converts the number to a duration, in years.
Operation codes MONITOR Begins a group of operations with conditional error handling.
ON-ERROR Performs conditional error handling, based on the status code.
ENDMON Ends a group of operations with conditional error handling.
ELSEIF Equivalent to an ELSE operation code followed by an IF operation code.
CRTBNDRPG and CRTRPGMOD keywords LICOPT(options) Specifies Licensed Internal Code options.