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
- 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".
- 7.2 Reference: What's new in 7.2: https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/rzasd/rpgrelv7r2.htm
Here's a little example that illustrates each of the new free-form statement types.
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');
prtDs.name = transform(caller_name);
write qprint prtDs;
*inlr = '1';
dcl-pi *n varchar(50);
name 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.
Was this topic helpful?
17 December 2019