What's New in V3R7?

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 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:
  • Support for database null fields

    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.

  • Expression intermediate result precision

    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.

  • New floating point data type

    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.

  • Support for null terminated strings

    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.

  • Pointer addition and subtraction

    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.

  • Support for long names

    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.

  • New built-in functions
    A number of new built-in functions have been added to the language which improve the following language facilities:
    • editing (%EDITW, %EDITC, %EDITFLT)
    • scanning strings (%SCAN)
    • type conversions (%INT, %FLOAT, %DEC, %UNS)
    • type conversions with half-adjust (%INTH, %DECH, %UNSH)
    • precision of intermediate results for decimal expressions (%DEC)
    • length and decimals of variables and expressions (%LEN, %DECPOS)
    • absolute value (%ABS)
    • set and test null-capable fields (%NULLIND)
    • handle null terminated strings (%STR)
  • Conditional compilation
    RPG IV has been extended to support conditional compilation. This support will include the following:
    • defining conditions (/DEFINE, /UNDEFINE),
    • testing conditions (/IF, /ELSEIF, /ELSE, /ENDIF)
    • stop reading current source file (/EOF)
    • a new command option (DEFINE) to define up to 32 conditions on the CRTBNDRPG and CRTRPGMOD commands.
  • Date enhancements

    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.

  • Character comparisons with alternate collating sequence

    Specific character variables can be defined so that the alternate collating sequence is not used in comparisons.

  • Nested /COPY members

    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.

  • Storage management

    You can now use the new storage management operation codes to allocate, reallocate and deallocate storage dynamically.

  • Status codes for storage management and float underflow errors.

    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.

Table 1. Changed Language Elements Since V3R6
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.
Table 2. New Language Elements Since V3R6
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 and %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 and %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 and %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.