What's New in 7.2?
This section describes the enhancements made to ILE RPG in 7.2.
- Free-form Control, File, Definition, and Procedure statements
- Free-form Control statements begin with CTL-OPT and
end with a semicolon. See Free-Form Control Statement.
CTL-OPT OPTION(*SRCSTMT : *NODEBUGIO) ALWNULL(*USRCTL);
- Free-form File definition statements begin with DCL-F and
end with a semicolon. See Free-Form File Definition Statement. The following statements define three files
- An externally-described DISK file opened for input and update.
- An externally-described WORKSTN file opened for input and output.
- A program-described PRINTER file with record-length 132.
DCL-F custFile usage(*update) extfile(custFilename); DCL-F screen workstn; DCL-F qprint printer(132) oflind(qprintOflow);
- Free-form data definition statements begin with DCL-C, DCL-DS, DCL-PI, DCL-PR,
or DCL-S, and end with a semicolon. See Free-Form Definition Statement. The following statements define several items
- A named constant MAX_ELEMS.
- A standalone varying length character field fullName.
- A qualified data structure with an integer subfield num and a UCS-2 subfield address.
- A prototype for the procedure 'Qp0lRenameUnlink'.
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;
- Free-form Procedure definition statements begin with DCL-PROC and
end with a semicolon. The END-PROC statement is
used to end a procedure. See Free-Form Procedure Statement.
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;
- The /FREE and /END-FREE directives are no longer required. The compiler will ignore them.
- Free-form statements and fixed-form statements may be intermixed.
IF endDate < beginDate; C GOTO internalError ENDIF; duration = %DIFF(endDate : beginDate : *days); . . . C internalError TAG
- Free-form Control statements begin with CTL-OPT and
end with a semicolon. See Free-Form Control Statement.
- CCSID support for alphanumeric data
-
- The default alphanumeric CCSID for the module can be set to many more CCSIDs including UTF-8 and hexadecimal.
- Alphanumeric data can be defined with a CCSID. Supported CCSIDs
include
- Single-byte and mixed-byte EBCDIC CCSIDs
- Single-byte and mixed-byte ASCII CCSIDs
- UTF-8
- Hexadecimal
- CCSID of external alphanumeric subfields
- Use CCSID(*EXACT) for an externally-described data structure to indicate that the alphanumeric subfields should have the same CCSID as the fields in the file.
- CCSID conversion is not performed for hexadecimal data
- CCSID conversion is not allowed for implicit or explicit conversion
of hexadecimal data. Hexadecimal data includes
- Hexadecimal literals
- Alphanumeric and graphic data defined with CCSID(*HEX)
- Alphanumeric and graphic data in buffers for externally-described files when the DATA keyword is in effect for the file and the CCSID of the field in the file is 65535
- Alphanumeric and graphic data in externally-described data structures defined with CCSID(*EXACT) when the CCSID of the field in the file is 65535
- Implicit conversion for concatenation
- The compiler will perform implicit conversion between alphanumeric, graphic, and UCS-2 data for concatenation expressions. See Conversions.
- Open database files without conversion to the job CCSID
- Use Control keyword OPENOPT(*NOCVTDATA) or File keyword DATA(*NOCVT) to specify that a database file will be opened so that alphanumeric and graphic data will not be converted to and from the job CCSID for input and output operations. See OPENOPT (*{NO}INZOFL *{NO}CVTDATA).
- Temporarily change the default CCSIDs, date format, or time format
- Use the /SET and /RESTORE directives to set default values for date formats, time formats, and CCSIDs. See /SET.
- Control the length returned by %SUBDT
- An optional third parameter for %SUBDT allows
you to specify the number of digits in the result.
For example, you can return the value of the
years as a four-digit value: %SUBDT(MyDate:*YEARS:4).
See %SUBDT (Extract a Portion of a Date, Time, or Timestamp).
- Increased precision for timestamp data
- Timestamp data can have between 0 and 12 fractional seconds. See Timestamp Data Type.
- Open Access files
- An Open Access file is a file which has all its operations handled by a user-written program or procedure, rather than by the operating system. This program or procedure is called an "Open Access Handler" or simply a "handler". The HANDLER keyword specifies the handler. See Open Access Files.
- New XML-INTO options
-
- XML namespaces are supported by the "ns" and "nsprefix" options. See ns option and nsprefix option.
- XML names with characters that are not supported by RPG for subfield names are supported by the "case=convert" option. See case option.
- Support for CCSID conversions that cause a loss of data when a source character does not exist in the target character set
- Control-specification keyword CCSIDCVT(*EXCP : *LIST). See CCSIDCVT(*EXCP | *LIST).
- Use CCSIDCVT(*EXCP) to get an exception if a CCSID conversion loses data due to the source character not having a match in the target character set.
- Use CCSIDCVT(*LIST) to get a listing of every CCSID conversion in the module, with a diagnostic message indicating whether the conversion has the potential of losing data.
- VALIDATE(*NODATETIME) to allow the RPG compiler to skip the validation step when working with date, time and timestamp data
-
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.
Warning: Skipping the validation step can lead to serious data corruption problems. You should only use this feature when you are certain that your date, time, and timestamp data is always valid.
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. |