IBM Support

Fall 2019 enhancements for RPG - DATA-GEN, OVERLOAD, OPTIONS(*EXACT)

General Page

You are in: RPG Cafe > Fall 2019 enhancements for RPG

Short URL: http://ibm.biz/fall_2019_rpg_enhancements

RPG Cafe: Fall 2019 enhancements

Several 7.3 and 7.4 enhancements for ILE RPG:

  • The DATA-GEN operation code
  • The OVERLOAD keyword for prototypes
  • OPTIONS(*EXACT) for prototyped parameters

PTFs, available 15 November 2019

7.3:

  • ILE RPG runtime: SI71535
  • ILE RPG compiler: SI71534
  • Source files in library QOAR for DATA-GEN: SI71517

7.4:

  • ILE RPG runtime: SI71537
  • ILE RPG compiler: SI71536
  • ILE RPG compiler, TGTRLS(V7R3M0): SI71538
  • Source files in library QOAR for DATA-GEN: SI71518

The PTFs for the compiler and runtime are also available with the Db2 for i Fix Packs of 15 November 2019. See https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM i Technology Updates/page/Db2 for IBM i 2019 Group PTF Schedule. However, the PTFs that provide the updates for library QOAR are not part of the Db2 for i Fix Packs, since they have special instructions regarding saving any changed source in any of the files.

Details

New operation code DATA-GEN

DATA-GEN generates a structured document, such as JSON or CSV, from an RPG variable. It requires a generator to generate the document. The DATA-GEN operation calls the generator, passing it the names and values of the RPG variables. The generator passes the text for the structured document back to the DATA-GEN operation, which places the information into the output file or the output RPG variable.

       DCL-DS product QUALIFIED;
          name VARCHAR(25);
          id CHAR(10);
          price PACKED(9 : 2);
       END-DS product;

       DATA-GEN product %DATA('ProductInfo.JSON' : 'doc=file')
                        %GEN('MYLIB/MYJSONGEN');

Overloaded prototypes

The OVERLOAD keyword defines a list of other prototypes that can be called by using the name of the prototype with the OVERLOAD keyword. When the prototype with the OVERLOAD keyword is used in a call operation, the compiler uses the parameters specified for the call to determine which of the candidate prototypes listed in the OVERLOAD keyword to call.

In the following example, FORMAT is defined with the OVERLOAD keyword. For the first call to FORMAT, the parameter has type Date, so FORMAT_DATE is called. For the second call to FORMAT, the parameter has type Time, so FORMAT_TIME is called. For the second call to FORMAT, the parameters have type Character, so FORMAT_MESSAGE is called.

       DCL-PR format_date VARCHAR(100);
          dateParm DATE(*ISO) CONST;
       END-PR;

       DCL-PR format_time VARCHAR(100);
          timeParm TIME(*ISO) CONST;
       END-PR;

       DCL-PR format_message VARCHAR(100);
          msgid CHAR(7) CONST;
          replacement_text VARCHAR(100) CONST OPTIONS(*NOPASS);
       END-PR;

       DCL-PR format VARCHAR(100) OVERLOAD(format_time : format_date : format_message);
       DCL-S result varchar(50);

       result = format(%date());      // 1
       result = format(%time());      // 2
       result = format('MSG0100' : filename); // 3

OPTIONS(*EXACT) for prototyped parameters

When OPTIONS(*EXACT) is specified for a prototyped parameter, extra rules apply to ensure that the called procedure receives the same value as the passed parameter. For example, without OPTIONS(*EXACT), the compiler allows the passed parameter to be longer than the prototyped parameter. The compiler also allows a data structure to be passed that is related by LIKEDS to a different data structure from the passed parameter. With OPTIONS(*EXACT), the passed parameter cannot be longer than the prototyped parameter, and if the prototyped parameter is defined with LIKEDS keyword, the passed parameter must be related by LIKEDS to the same data structure.

In the following example, field fld10 can be passed to parameter parm5 of prototype p1, but the called procedure receives the value "abcde" instead of the full value 'abcdefghij' of fld10.  Field fld10 cannot be passed to parameter parm5Exact of prototype p2 because the length, 10, of fld10 is greater than the length, 5, of the prototyped parameter parm5Exact.

       DCL-PR p1;
          parm5 char(5);
       END-PR;
       DCL-PR p2;
          parm5Exact char(5) OPTIONS(*EXACT);
       END-PR;
       DCL-S fld10 CHAR(10) INZ('abcdefghij');

       p1 (fld10);
       p2 (fld10);  // Error

Source files in QOAR for DATA-GEN

Files H, QCBLLESRC, and QRPGLESRC have the following changes:

  • Member QRNDTAGEN is added
  • Member QRNTYPES is added with some constant definitions
  • Member QRNOPENACC is updated to include QRNTYPES for some of the constant definitions

File SAMPLE2 is added with sample source for the DATA-GEN operation code:

  • Member XMLGEN is a sample generator for XML. Read the comments at the beginning of the source member for the %GEN options you can specify.
  • Member XMLGENTST is a test program for XMLGEN.
  • Member PROPGEN has some educational generators that generate "properties files".
  • Member PROPGENB is binder source for the PROPGEN service program.
  • Member PROPGENC is a copy file for the PROPGEN generators.
  • Member PROPGENTST is a test program for the PROPGEN generators.

RDi support

This section will be updated when RDi support for the new features is available.

Documentation in the IBM Knowledge Center

The ILE RPG Reference and ILE RPG Programmer's Guide in the 7.3 and 7.4 IBM Knowledge Center are updated with full information about these enhancements. Start at the What's New Since 7.3 or What's New Since 7.4 section in the Reference.

The Open Access: RPG Edition for 7.3 and 7.4 is updated with information about how to write a generator for the DATA-GEN operation code.

Snippet of RPG source code

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SS69QP","label":"Rational Development Studio for i"},"Component":"ILE RPG Compiler","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
29 December 2019

UID

ibm11106409