The major enhancements to RPG IV since V3R6 are the new support for database null fields, and the ability to better control the precision of intermediate results in expressions. Other enhancements include the addition of a floating point data type and support for null-terminated strings. These further improve the RPG product for integration with the OS/400 operating system and ILE interlanguage communication. This means greater flexibility for developing applications.
The following is a list of these enhancements including a number of new built-in functions and usability enhancements:
This enhancement allows users to process database files which contain null-capable fields, by allowing these fields to be tested for null and set to null.
A new control specification keyword and new operation code extenders on free-form expression specifications allow the user better control over the precision of intermediate results.
The new floating point data type has a much larger range of values than other data types. The addition of this data type will improve integration with the database and improve interlanguage communication in an ILE environment, specifically with the C and C++ languages.
The new support for null terminated strings improves interlanguage communication. It allows users full control over null terminated data by allowing users to define and process null terminated strings, and to conveniently pass character data as parameters to procedures which expect null terminated strings.
Free-form expressions have been enhanced to allow adding an offset to a pointer, subtracting an offset from a pointer, and determining the difference between two pointers.
Names longer than 10 characters have been added to the RPG language. Anything defined on the definition or procedure specifications can have a long name and these names can be used anywhere where they fit within the bounds of an entry. In addition, names referenced on any free-form specification may be continued over multiple lines.
A number of new built-in functions have been added to the language which improve the following language facilities:
RPG IV has been extended to support conditional compilation. This support will include the following:
Several enhancements have been made to improve date handling operations. The TIME operation code is extended to support Date, Time or Timestamp fields in the result field. Moving dates or times from and to character fields no longer requires separator characters. Moving UDATE and *DATE fields no longer requires a format code to be specified. Date fields can be initialized to the system (*SYS) or job (*JOB) date on the definition specifications.
Specific character variables can be defined so that the alternate collating sequence is not used in comparisons.
You can now nest /COPY directives. That is, a /COPY member may contain one (or more) /COPY directives which can contain further /COPY directives and so on.
You can now use the new storage management operation codes to allocate, reallocate and deallocate storage dynamically.
Two status codes 425 and 426 have been added to indicate storage management errors. Status code 104 was added to indicate that an intermediate float result is too small.
The following tables summarize the changed and new language elements, based on the part of the language affected.
Language Unit | Element | Description |
---|---|---|
Definition specification keywords | ALIGN | ALIGN can now be used to align float subfields along with the previously supported integer and unsigned alignment. |
OPTIONS(*NOPASS *OMIT *VARSIZE *STRING) | The *STRING option allows you to pass a character value as a null-terminated string. | |
Record address type | F (Float format) | Added to the list of allowed record address types on the file description specifications. Signals float processing for a program described file. |
Internal data type | F (Float format) | Added to the list of allowed internal data types on the definition specifications. Defines a floating point standalone field, parameter, or data structure subfield. |
Data format | F (Float format) | Added to the list of allowed data formats on the input and output specifications for program described files. |
Language Unit | New | Description |
---|---|---|
Control specification keywords | COPYNEST('1-2048') | Specifies the maximum depth for nesting of /COPY directives. |
EXPROPTS(*MAXDIGITS | *RESDECPOS) | Expression options for type of precision (default or "Result Decimal Position" precision rules) | |
FLTDIV{(*NO | *YES)} | Indicates that all divide operations in expressions are computed in floating point. | |
Definition specification keywords | ALTSEQ(*NONE) | Forces the normal collating sequence to be used for character comparison even when an alternate collating sequence is specified. |
Built-in functions | %ABS | Returns the absolute value of the numeric expression specified as the parameter. |
%DEC & %DECH | Converts the value of the numeric expression to decimal (packed) format with the number of digits and decimal positions specified as parameters. %DECH is the same as %DEC, but with a half adjust applied. | |
%DECPOS | Returns the number of decimal positions of the numeric variable or expression. The value returned is a constant, and may be used where a constant is expected. | |
%EDITC | This function returns a character result representing the numeric value edited according to the edit code. | |
%EDITFLT | Converts the value of the numeric expression to the character external display representation of float. | |
%EDITW | This function returns a character result representing the numeric value edited according to the edit word. | |
%FLOAT | Converts the value of the numeric expression to float format. | |
%INT & %INTH | Converts the value of the numeric expression to integer. Any decimal digits are truncated with %INT and rounded with %INTH. | |
%LEN | Returns the number of digits or characters of the variable expression. | |
%NULLIND | Used to query or set the null indicator for null-capable fields. | |
%SCAN | Returns the first position of the search argument in the source string, or 0 if it was not found. | |
%STR | Used to create or use null-terminated strings, which are very commonly used in C and C++ applications. | |
%UNS & %UNSH | Converts the value of the numeric expression to unsigned format. Any decimal digits are truncated with %UNS and rounded with %UNSH. | |
Operation code Extenders | N | Sets pointer to *NULL after successful DEALLOC |
M | Default precision rules | |
R | No intermediate value will have fewer decimal positions than the result ("Result Decimal Position" precision rules) | |
Operation codes | ALLOC | Used to allocate storage dynamically. |
DEALLOC | Used to deallocate storage dynamically. | |
REALLOC | Used to reallocate storage dynamically. |