This section describes the enhancements made to ILE RPG in 7.2.
CTL-OPT OPTION(*SRCSTMT : *NODEBUGIO)
ALWNULL(*USRCTL);
DCL-F custFile usage(*update) extfile(custFilename);
DCL-F screen workstn;
DCL-F qprint printer(132) oflind(qprintOflow);
DCL-C MAX_ELEMS 1000;
DCL-S fullName VARCHAR(50)
INZ('Unknown name');
DCL-DS ds1 QUALIFIED;
num INT(10);
address UCS2(100);
END-DS;
DCL-PR Qp0lRenameUnlink INT(10) EXTPROC(*DCLCASE);
oldName POINTER VALUE OPTIONS(*STRING);
newName POINTER VALUE OPTIONS(*STRING);
END-PR;
The following example shows a free-form subprocedure definition.
DCL-PROC getCurrentUserName EXPORT;
DCL-PI *n CHAR(10) END-PI;
DCL-S curUser CHAR(10) INZ(*USER);
RETURN curUser;
END-PROC;
IF endDate < beginDate;
C GOTO internalError
ENDIF;
duration = %DIFF(endDate : beginDate : *days);
. . .
C internalError TAG
See %SUBDT (Extract a Portion of a Date, Time, or Timestamp).
Use Control-specification keyword VALIDATE(*NODATETIME) to allow the RPG compiler to treat date, time, and timestamp data as character data, without performing the checks for validity. See VALIDATE(*NODATETIME).
This may improve the performance of some date, time, and timestamp operations.
| Element | Description |
|---|---|
| CCSID keyword |
|
| DFTACTGRP keyword | DFTACTGRP(*NO) is assumed if there are any free-form Control specifications, and at least one of the ACTGRP, BNDDIR, or STGMDL keywords is used. See DFTACTGRP(*YES | *NO). |
| OPENOPT keyword | OPENOPT(*{NO}CVT) controls the default for
the DATA keyword for database files.
|

| Element | Description |
|---|---|
| /FREE and /END-FREE directives | These directives are no longer necessary to indicate the beginning and ending of free-form code. They are ignored by the compiler. See /FREE... /END-FREE. |

| Element | Description |
|---|---|
| CCSID keyword |
|
| DTAARA keyword | In a free-form definition:
See DTAARA keyword. |
| EXTFLD keyword | In a free-form subfield definition
See EXTFLD{(field_name)}. |
| EXTNAME keyword | In a free-form data structure definition
See EXTNAME(file-name{:format-name}{:*ALL| *INPUT|*OUTPUT|*KEY}). |
| EXPORT and IMPORT keywords | In a free-form definition
|
| EXTPROC keyword | In a free-form prototype definition or a procedure-interface
definition
See EXTPROC({*CL|*CWIDEN|*CNOWIDEN| {*JAVA:class-name:}}name). |
| LIKE keyword | In a free-form definition, the LIKE keyword has an optional second parameter specifying the length adjustment. |
| LEN keyword | In a free-form definition, the LEN keyword
is allowed only for a data structure definition.
For other free-form definitions, the length is specified
as part of the data-type keyword.
See LEN(length). |
| CLASS, DATFMT, PROCPTR, TIMFMT, and VARYING keywords | These keywords are not used in a free-form definition. The information specified by these keywords is specified as part of the related data-type keywords. |
| FROMFILE, PACKEVEN, and TOFILE keywords | These keywords are not allowed in a free-form definition. |
| OVERLAY keyword | The parameter cannot be the name of the data structure for a free-form subfield definition. The POS keyword is used instead. |

| Element | Description |
|---|---|
| Timestamp literals | Timestamp literals can
have between 0 and 12 fractional seconds. See Literals. |

| Element | Description |
|---|---|
| File and Definition statements | File and Definition statements can be intermixed. |

| Element | Description |
|---|---|
| %CHAR | When the operand is a timestamp, the length of the returned value depends on the number of bytes in the timestamp. If the format is *ISO0, the number of bytes can be between 14 and 26. If the format is *ISO, the number of bytes can be 19, or between 21 and 32. |
| %DEC | When the operand is a timestamp, the number of digits can be between 14 and 26, depending on the number of fractional seconds in the timestamp. |
| %DIFF | When the operand is a timestamp,
an optional fourth parameter specifies the number
of fractional seconds to return.
See %DIFF (Difference Between Two Date, Time, or Timestamp Values). |
| %SECONDS | When %SECONDS is used to add seconds to a timestamp, the parameter can have decimal positions specifying the number of fractional seconds. |
| %SUBDT |
See %SUBDT (Extract a Portion of a Date, Time, or Timestamp). |
| %TIMESTAMP |
|

| Element | Description |
|---|---|
| Length entry | The length entry for a timestamp can be 19, or a value between 21 and 32. |
| Decimal-positions entry | The decimal-positions entry for a timestamp can be a value between 0 and 12. |

| Element | Description |
|---|---|
| /SET directive | Temporarily set a new value for the following
Control statement keywords:
These values are used to supply a default value for definition statements when the value is not explicitly provided on the definition. See /SET. |
| /RESTORE directive | Restore the previous setting to the value it
had before the most recent /SET directive that set the value.:
|

| Element | Description |
|---|---|
| CTL-OPT | Begins a free-form Control statement |
| DCL-F | Begins a free-form File definition |
| DCL-C | Begins a free-form Named Constant definition |
| DCL-DS | Begins a free-form Data Structure definition |
| DCL-SUBF | Begins a free-form Subfield definition. Specifying "DCL-SUBF" is optional unless the subfield name is the same as an operation code allowed in free-form calculations. |
| END-DS | Ends a free-form Data Structure definition. If there are no subfields, it can be specified after the last keyword of the DCL-DS statement. |
| DCL-PI | Begins a free-form Procedure Interface definition |
| DCL-PR | Begins a free-form Prototype definition |
| DCL-PARM | Begins a free-form Parameter definition. Specifying "DCL-PARM" is optional unless the parameter name is the same as an operation code allowed in free-form calculations . |
| END-PI | Ends a free-form Procedure Interface definition. If there are no parameters, it can be specified after the last keyword of the DCL-PI statement. |
| END-PR | Ends a free-form Prototype definition. If there are no parameters, it can be specified after the last keyword of the DCL-PR statement. |
| DCL-S | Begins a free-form Standalone Field definition |
| DCL-PROC | Begins a free-form Procedure definition |
| END-PROC | Ends a free-form Procedure definition |

| Element | Description |
|---|---|
| CCSIDCVT(*EXCP | *LIST) | Allows you to control how the compiler handles conversions between data with different CCSIDs. |
| VALIDATE(*NODATETIME) | Specifies whether Date, Time and Timestamp data must be validated before it is used. |
| Element | Description |
|---|---|
| DATA(*{NO}CVT) | Controls whether a file is opened so that database
performs CCSID conversion to and from the job CCSID for alphanumeric
and graphic fields. See DATA(*CVT | *NOCVT). |
| HANDLER(handler {:communication-area}) | Specifies that the file is an Open Access file. |
| DISK{(*EXT | record-length)} | Device keywords to specify the
device type of a free-form File definition.
See File devices. |
| PRINTER{(*EXT | record-length)} | |
| SEQ{(*EXT | record-length)} | |
| SPECIAL{(*EXT | record-length)} | |
| WORKSTN{(*EXT | record-length)} | |
| USAGE(*INPUT *OUTPUT *UPDATE *DELETE) | Specifies the usage of the file in a free-form file definition. |
| KEYED{(*CHAR : key-length)} | Indicates that the file is keyed in a free-form file definition. |

| Element | Description |
|---|---|
| CHAR(length) | Fixed-length alphanumeric data type See CHAR(length). |
| VARCHAR(length {:prefix-size}) | Varying-length alphanumeric data type |
| GRAPH(length) | Fixed-length Graphic data type See GRAPH(length). |
| VARGRAPH(length {:prefix-size}) | Varying-length Graphic data type |
| UCS2(length) | Fixed-length UCS-2 data type See UCS2(length). |
| VARUCS2(length {:prefix-size}) | Varying-length UCS-2 data type |
| IND | Indicator data type See IND. |
| INT(digits) | Integer data type See INT(digits). |
| UNS(digits) | Unsigned integer data type See UNS(digits). |
| PACKED(digits {:decimals}) | Packed decimal data type |
| ZONED(digits {:decimals}) | Zoned decimal data type |
| BINDEC(digits {:decimals}) | Binary decimal data type |
| FLOAT(size) | Float data type See FLOAT(bytes). |
| DATE{(format)} | Date data type |
| TIME{(format)} | Time data type |
| TIMESTAMP {(fractional seconds)} | Timestamp data type |
| POINTER{(*PROC)} | Pointer data type. The optional parameter *PROC
indicates that it is a procedure pointer. See POINTER{(*PROC)}. |
| OBJECT{(*JAVA : class-name)} | Object data type. The parameters are optional if it is defining the return type of a Java™ constructor. |

| Element | Description |
|---|---|
| EXT | Indicates that a data structure is externally described. This keyword is optional if the EXTNAME keyword is specified as the first keyword for a data structure definition. See EXT. |
| POS(subfield-start-position) | Specifies the starting position of a subfield in the data structure. |
| PSDS | Specifies that the data structure is a Program Status Data Structure. See PSDS. |

