I found this on "some" site and I actually didnt know a couple of
these - for example the %dec and the %trim replacement characters...
so I thought Id share with you..
The following list describes the enhancements made to ILE RPG in V5R3:
* New builtin function %SUBARR:
New builtin function %SUBARR allows assignment to a sub-array or returning a
sub-array as a value.
Along with the existing %LOOKUP builtin function, this enhancements enables
the implementation of dynamically sized arrays with a varying number of elements.
%SUBARR(array : start) specifies array elements array(start) to the end of the array
%SUBARR(array : start : num) specifies array elements array(start) to
array(start + num - 1)
Example:
* The SORTA operation code is enhanced to allow sorting of partial arrays.
When %SUBARR is specified in factor 2, the sort only affects the partial array
indicated by the %SUBARR builtin function.
* Direct conversion of date/time/timestamp to numeric, using %DEC:
%DEC is enhanced to allow the first parameter to be a date, time or timestamp,
and the optional second parameter to specify the format of the resulting numeric value.
Example:
* Control specification CCSID(*CHAR : *JOBRUN) for correct conversion of
character data at runtime:
The Control specification CCSID keyword is enhanced to allow a first parameter
of *CHAR. When the first parameter is *CHAR, the second parameter must be *JOBRUN.
CCSID(*CHAR : *JOBRUN) controls the way character data is converted to UCS-2 at
runtime. When CCSID(*CHAR:*JOBRUN) is specified, character data will be assumed
to be in the job CCSID; when CCSID(*CHAR : *JOBRUN) is not specified, character
data will be assumed to be in the mixed-byte CCSID related to the job CCSID.
* Second parameter for %TRIM, %TRIMR and %TRIML indicating what characters to trim:
%TRIM is enhanced to allow an optional second parameter giving the list of
characters to be trimmed.
Example:
* New prototype option OPTIONS(*TRIM) to pass a trimmed parameter:
When OPTIONS(*TRIM) is specified on a prototyped parameter, the data that
is passed be trimmed of leading and trailing blanks. OPTIONS(*TRIM) is valid
for character, UCS-2 and graphic parameters defined with CONST or VALUE. It
is also valid for pointer parameters defined with OPTIONS(*STRING). With
OPTIONS(*STRING : *TRIM), the passed data will be trimmed even if a
pointer is passed on the call.
Example:
* Support for 63 digit packed and zoned decimal values
Packed and zoned data can be defined with up to 63 digits and 63 decimal positions.
The previous limit was 31 digits.
* Relaxation of the rules for using a result data structure for I/O to
externally-described files and record formats
o The result data structure for I/O to a record format may be an
externally-described data structure.
o A data structure may be specified in the result field for I/O
to an externally-described file name for operation codes
CHAIN, READ, READE, READP and READPE.
Examples:
1. The following program writes to a record format using from an externally-described data structure.
these - for example the %dec and the %trim replacement characters...
so I thought Id share with you..
The following list describes the enhancements made to ILE RPG in V5R3:
* New builtin function %SUBARR:
New builtin function %SUBARR allows assignment to a sub-array or returning a
sub-array as a value.
Along with the existing %LOOKUP builtin function, this enhancements enables
the implementation of dynamically sized arrays with a varying number of elements.
%SUBARR(array : start) specifies array elements array(start) to the end of the array
%SUBARR(array : start : num) specifies array elements array(start) to
array(start + num - 1)
Example:
PHP Code:
// Copy part of an array to another array:
resultArr = %subarr(array1:start:num);
// Copy part of an array to part of another array:
%subarr(Array1:x:y) = %subarr(Array2:m:n);
// Sort part of an array
sorta %subarr(Array3:x:y);
// Sum part of an array
sum = %xfoot(%subarr(Array4:x:y));
When %SUBARR is specified in factor 2, the sort only affects the partial array
indicated by the %SUBARR builtin function.
* Direct conversion of date/time/timestamp to numeric, using %DEC:
%DEC is enhanced to allow the first parameter to be a date, time or timestamp,
and the optional second parameter to specify the format of the resulting numeric value.
Example:
PHP Code:
D numDdMmYy s 6p 0
D date s d datfmt(*jul)
date = D'2003-08-21';
numDdMmYy = %dec(date : *dmy);
// now numDdMmYy = 210803
character data at runtime:
The Control specification CCSID keyword is enhanced to allow a first parameter
of *CHAR. When the first parameter is *CHAR, the second parameter must be *JOBRUN.
CCSID(*CHAR : *JOBRUN) controls the way character data is converted to UCS-2 at
runtime. When CCSID(*CHAR:*JOBRUN) is specified, character data will be assumed
to be in the job CCSID; when CCSID(*CHAR : *JOBRUN) is not specified, character
data will be assumed to be in the mixed-byte CCSID related to the job CCSID.
* Second parameter for %TRIM, %TRIMR and %TRIML indicating what characters to trim:
%TRIM is enhanced to allow an optional second parameter giving the list of
characters to be trimmed.
Example:
PHP Code:
trimchars = '*-.';
data = '***a-b-c-.'
result = %trim(data : trimchars);
// now result = 'a-b-c'. All * - and . were trimmed from the ends of the data
When OPTIONS(*TRIM) is specified on a prototyped parameter, the data that
is passed be trimmed of leading and trailing blanks. OPTIONS(*TRIM) is valid
for character, UCS-2 and graphic parameters defined with CONST or VALUE. It
is also valid for pointer parameters defined with OPTIONS(*STRING). With
OPTIONS(*STRING : *TRIM), the passed data will be trimmed even if a
pointer is passed on the call.
Example:
PHP Code:
D proc pr
D parm1 5a const options(*trim)
D parm2 5a const options(*trim : *rightadj)
D parm3 5a const varying options(*trim)
D parm4 * value options(*string : *trim)
D parm5 * value options(*string : *trim)
D ptr s *
D data s 10a
D fld1 s 5a
/free
data = ' rst ' + x'00';
ptr = %addr(data);
proc (' xyz ' : ' @#$ ' : ' 123 ' : ' abc ' : ptr);
// the called procedure receives the following parameters
// parm1 = 'xyz '
// parm2 = ' @#$'
// parm3 = '123'
// parm4 = a pointer to 'abc.' (where . is x'00')
// parm5 = a pointer to 'rst.' (where . is x'00')
Packed and zoned data can be defined with up to 63 digits and 63 decimal positions.
The previous limit was 31 digits.
* Relaxation of the rules for using a result data structure for I/O to
externally-described files and record formats
o The result data structure for I/O to a record format may be an
externally-described data structure.
o A data structure may be specified in the result field for I/O
to an externally-described file name for operation codes
CHAIN, READ, READE, READP and READPE.
Examples:
1. The following program writes to a record format using from an externally-described data structure.
PHP Code:
Foutfile o e k disk
D outrecDs e ds extname(outfile) prefix(O_)
/free
O_FLD1 = 'ABCDE';
O_FLD2 = 7;
write outrec outrecDs;
*inlr = *on;
/end-free
2. The following program reads from a multi-format logical file into
data structure INPUT which contains two overlapping subfields
holding the fields of the respective record formats.
Flog if e k disk infds(infds)
D infds ds
D recname 261 270
D input ds qualified
D rec1 likerec(rec1) overlay(input)
D rec2 likerec(rec2) overlay(input)
/free
read log input;
dow not %eof(log);
dsply recname;
if recname = 'REC1';
// handle rec1
elseif recname = 'REC2';
// handle rec2
endif;
read log input;
enddo;
*inlr = *on;
/end-free
Comment