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:

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

Free-form H F D and P statements


  • 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".


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

       ctl-opt dftactgrp(*no);
       dcl-pi *n;
char(10) const;
       dcl-c RECORD_LEN 80;
       dcl-f qprint printer(RECORD_LEN); 
       dcl-ds prtDs len(RECORD_LEN) qualified;
char(6) inz('Hello');
       end-ds; = transform(caller_name);
       write qprint prtDs;
= '1';

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

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":"BU054","label":"Systems 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":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
17 December 2019