RPGIV @ Work

A unique site for RPG and System i Lovers


Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

RPG Fully Free now Print E-mail
User Rating: / 0
Written by Chamara   

As part of IBM i 7.1 Technology Refresh 7, a major enhancement to RPG IV is being announced: Free-form control, file-declaration, data-declaration, and procedure statements.

Read the announcement here: http://www-01.ibm.com/common/ssi/cgi-bin/ssialias?infotype=AN&subtype=CA&htmlfid=897/ENUS213-423&appname=USN


This enhancement will be available through a 7.1 PTF in November, 2013. This page will be updated in November with the PTF details.

Here's a little example that illustrates each of the new free-form statement types.

       ctl-opt dftactgrp(*no);

       dcl-pi *n;
          caller_name char(10) const;

       dcl-c RECORD_LEN 80;

       dcl-f qprint printer(RECORD_LEN);

       dcl-ds prtDs len(RECORD_LEN) qualified;
          *n char(6) inz('Hello');
          name char(50);

       prtDs.name = transform(caller_name);
       write qprint prtDs;

       *inlr = '1';

       dcl-proc transform;
          dcl-pi *n varchar(50);
             name varchar(10) const options(*trim);

          return '*** ' + name + ' ***';

A few things to notice about the example:

  • Each statement (except for parameter and subfield declarations) starts with an opcode, either CTL-OPT for control statements, or DCL-x for declarations, and ends with a semicolon. Subfield and parameter declarations also start with an opcode, DCL-SUBF or DCL-PARM, but just like the EVAL and CALLP opcodes, you can omit the opcode for subfields and parameters.
  • The parameter for the "transform" procedure is defined as VARCHAR(10). The VARYING keyword isn't used in free-form. When you look at the full list of data-type keywords, you'll notice that several of them combine the fixed-form data-type value of A, C, D, O, T etc with a fixed-form keyword like VARYING, DATFMT, CLASS, TIMFMT etc.
  • A named constant is used for the record length of the printer file and the length of the data structure.
  • There's no /FREE at the beginning of the code. /FREE and /END-FREE are no longer needed to go between fixed form and free form. The compiler will just ignore them.
  • The procedure interface (PI) is coded before the file declaration in the main procedure. You can mix F and D specs even in fixed form.

It's not possible to explain all the details here. You can read all about the new syntax in an extra PDF that will been added to the 7.1 Info Center on October 8. Look for "PDF File for Updated ILE RPG Reference" in the RPG topic under Programming Languages. I recommend that you start with the "What's New Since 7.1" section. From there you can navigate to the detailed information about all the new features.

Unfortunately, while RPG is a lot freer, it still isn't completely free. There are still some restrictions:

  • Free-form code still has to be coded between columns 8 - 80
  • I and O specs are still only fixed-form.
  • There is no target-release support - it is only for TGTRLS(*CURRENT) on 7.1.

Note: The SQL precompiler will also have full support for the new free-form syntax.

Extraction from IBM Site - https://ibm.biz/BdDMwB

<Previous   Next>