What's New in 7.3?

This section describes the enhancements made to ILE RPG in 7.3.

Support for fully free-form source
RPG source with the special directive **FREE in the first line contains only free-form code. The code can begin in column 1 and extend to the end of the line.

There is no practical limit on the length of a source line in fully free-form source.

Fixed-form code is not allowed in fully free-form source, but column-limited source which uses only columns 6-80 can be included by using the /COPY or /INCLUDE directive.

See Fully free-form statements.

New built-in function %SCANR (Scan reverse)
The %SCANR built-in function is similar to the %SCAN built-in function, but it finds the last occurrence of the search argument rather than first occurrence.
The following example uses %SCAN to find the first occurrence of "***" in the string, and %SCANR to find the last occurrence.

   string = 'The title is *** Chapter 1 ***.';
   p1 = %SCAN ('***' : string);
   p2 = %SCANR ('***' : string);
   // p1 = 14
   // p2 = 28

See %SCANR (Scan Reverse for Characters).

Length parameter for built-in function %SCAN
The length parameter allows you to limit the amount of the source string that is searched.

In the following example, the first %SCAN built-in function returns 26. The second one returns 0 because the value "abc" is not found within the substring indicated by the start position of 1 and the length of 10.


   string = 'The alphabet begins with abc.';
   p1 = %SCAN ('abc' : string);
   p2 = %SCAN ('abc' : string : 1 : 10);
   // p1 = 26
   // p2 = 0

See %SCAN (Scan for Characters).

Extended ALIAS support for files
The ALIAS keyword can now be specified for any externally-described file.

If the ALIAS keyword is specified for a global file that is not qualified, the alternate names of the fields will be available for use in the RPG program.

In the following example, the field REQALC in the file MYFILE has the alternate name REQUIRED_ALLOCATION. The ALIAS keyword indicates that the name for this field within the RPG program will be REQUIRED_ALLOCATION. See ALIAS.


     dcl-f myfile ALIAS;

     read myfile;
     if required_allocation <> 0
     and size > 0;
       ...
Relaxed rules for data structures for I/O operations
  • An externally-described data structure or LIKEREC data structure defined with type *ALL can be used as the result data structure for any I/O operation. See File Operations.
    
         dcl-f myfile usage(*input : *output : *update);
         dcl-ds ds extname('MYFILE' : *ALL);
    
         read myfile ds;
         update myfmt ds;
         write myfmt ds;
    
  • When a data structure is defined for a record format of a DISK file using LIKEREC without the second parameter, and the output buffer layout is identical to the input buffer layout, the data structure can be used as the result data structure for any I/O operation.
    
         dcl-f myfile usage(*input : *output : *update);
         dcl-ds ds likerec(fmt);
    
         read myfile ds;
         update myfmt ds;
         write myfmt ds;
    
Enhancements related to null-capable fields
  • When a data structure is defined with the EXTNAME or LIKEREC keyword, *NULL may be coded as an additional extract type, specifying that the subfields are all indicators. If the external file is a database file, the resulting data structure matches the null byte map for the file. See EXTNAME(file-name{:format-name}{:*ALL| *INPUT|*OUTPUT|*KEY|*NULL}) and LIKEREC(intrecname{:extract-types}).
  • Use the NULLIND keyword to
    • define a field as null-capable
    • define your own indicator field to be the null-indicator for a field
    • define your own indicator data structure, defined with EXTNAME(*NULL) or LIKEREC(*NULL), to be the null-indicators for another data structure. See NULLIND{(null-indicator)}.
PCML enhancements
  • Specify the *DCLCASE parameter for the PGMINFO Control specification keyword to have the names in the program-interface information generated in the same case as the names are defined in the RPG source file. See PGMINFO(*PCML | *NO | *DCLCASE { : *MODULE | *V6 | *V7 ... } ).
  • Specify PGMINFO(*YES) in the Procedure specification keywords for the procedure that should be included in the program-interface information when a module is being created, or specify PGMINFO(*NO) for the procedures that should not be included. See PGMINFO(*YES | *NO).
DCLOPT(*NOCHGDSLEN)
Specify DCLOPT(*NOCHGDSLEN) to prevent changing the length of a data structure using an Input, Output, or Calculation specification. Specifying DCLOPT(*NOCHGDSLEN) allows %SIZE(data-structure) to be used in more free-form declarations. See DCLOPT(*NOCHGDSLEN).
Table 1. Changed Language Elements Since 7.2: Control specification keywords
Element Description
PGMINFO keyword *DCLCASE parameter to generate the names in the program-interface information in the same case as the names are coded in the RPG source file. See PGMINFO(*PCML | *NO | *DCLCASE { : *MODULE | *V6 | *V7 ... } ).
Table 2. Changed Language Elements Since 7.2: File specification keywords
Element Description
ALIAS keyword Allowed for all externally-described files See ALIAS.
Table 3. Changed Language Elements Since 7.2: Definition specification keywords
Element Description
EXTNAME keyword Extract type *NULL See EXTNAME(file-name{:format-name}{:*ALL| *INPUT|*OUTPUT|*KEY|*NULL}).
LIKEREC keyword Extract type *NULL See LIKEREC(intrecname{:extract-types}).
Table 4. Changed Language Elements Since 7.2: Built-in functions
Element Description
The %SCAN built-in function The %SCAN built-in function now supports a fourth parameter indicating the length to be searched. See %SCAN (Scan for Characters).
Table 5. New Language Elements Since 7.2: Directives
Element Description
Special directive **FREE **FREE indicates that the source is fully free-form, with RPG code from column 1 to the end of the source line. See Fully free-form statements.
Table 6. New Language Elements Since 7.2: Control specification keywords
Element Description
DCLOPT (*NOCHGDSLEN) keyword Disallow changing the size of a data structure using an Input, Output, or Calculation specification. See DCLOPT(*NOCHGDSLEN).
Table 7. New Language Elements Since 7.2: Definition specification keywords
Element Description
NULLIND keyword Associate one item as the null-indicator or null-indicators for another item. See NULLIND{(null-indicator)}.
Table 8. New Language Elements Since 7.2: Procedure specification keywords
Element Description
PGMINFO keyword Allows you to control which procedures have their interface described in the program-interface information when a module is being created. See PGMINFO(*YES | *NO).
Table 9. New Language Elements Since 7.2: Built-in functions
Element Description
%SCANR (Scan Reverse) Find the last occurrence of one string in another string. See %SCANR (Scan Reverse for Characters).