IBM Support

Free-form H, F, D and P statements for RPG

General Page

You are in: RPG Cafe > Free-form H, F, D, P specs

Short URL for this page: https://ibm.biz/rpgcafe_freeform_hfdp

RPG Cafe: Free-form H, F, D, P specs

Free-form H F D and P statements

PTFs

7.1:
  • ILE RPG compiler: SI51094
  • SQL precompiler: DB2 PTF Group SF99701 level 26

Documentation in the IBM Knowledge Center

The ILE RPG Reference for 7.2 has information about free-form H, F, D, and P specifications. Start at "What's New In 7.2".

Example

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;
       end-pi;
       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);
       end-ds;

   prtDs.name = transform(caller_name);
       write qprint prtDs;
   *inlr
= '1';

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

Things to note 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 notice that several of them combine the fixed-form data type value (A, C, D, O, T etc.) with a fixed-form keyword (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. If you code them, the compiler ignores 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.

[{"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:
17 December 2019

UID

ibm11108197