System i Resources
enskill.com

 

Onsite Classes
Expert System i training comes to you! RPG, SQL, WDSc and more.
 

DVD Training
Self-paced RPG IV classes and labs on your schedule.
 

System i Books
from leading System i authors.
 

e-Learning
Live instructor, no travel. Attend from your office or home.
 

Free Format

 *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8
 ..Opcode(E)-or-expression;+++++++++++++++++++++++++++++++++++++++++++++++++
Columns Description
1–5 Sequence number
6-7 (Blank)
8-80 Calculation entry (Operation code or expression, followed by a semicolon (;) )
81–100 Comments

Operation Codes and Built-in Functions

Opcode or Function Description
%ABS(numeric-expression) Absolute value
ACQ{(E)} device-name workstn-file Acquire a program device for a WORKSTN file
%ADDR(variable{(index-expression)}{:*DATA}) Get address pointer
%ALLOC(length) Allocate storage
BEGSR subroutine-name Begin a subroutine
%BITAND(expression : expression
{:expression…})
Bitwise ANDing of the bits of all arguments
%BITNOT(expression) Bitwise inverse of the bits of the argument
%BITOR(expression : expression
{:expression…})
Bitwise ORing of the bits of all arguments
%BITXOR(expression : expression) Bitwise exclusive ORing of the bits of two arguments
{CALLP{(EMR)}} name({parm1 : parm2 : …}) Call a prototyped procedure or program
CHAIN{(EHMNR)} search-argument file-format-name {data-structure} Random retrieval from a file
%CHAR(expression {: format}) Convert to character data
%CHECK(compare-string : base-string
{: start})
Check characters
%CHECKR(compare-string : base-string
{: start})
Check characters (reversed)
CLEAR {*NOKEY} {*ALL} structure-variable Clear data structure, variable, or record format
CLOSE{(E)} file-name | *ALL Close files
COMMIT{(E)} {boundary} Commit group
%DATE({expression {: format}}) Convert to date. See Date Formats
%DAYS(number) Number of days
DEALLOC{(EN)} pointer Free storage
%DEC(expression {: precision
: decimals})
%DEC(date-expression {: format})
%DECH(expression : precision : decimals)
Convert to packed decimal (with optional half adjust). See Date Formats
%DECPOS(numeric-expression) Get number of decimal positions
DELETE{(EHMR)} {search-argument} file-format-name Delete record
%DIFF(date1 : date2 : duration-code) Difference between two dates/times/timestamps
%DIV(dividend : divisor) Integer division
DOU{(MR)} logical-expression Do until
DOW{(MR)} logical-expression Do while
DSPLY{(E)} {message {message-queue {response}}} Display function
DUMP{(A)} {identifier} Program dump
%EDITC(numeric-expression : edit-code
{: fill})
Apply an edit code. See Edit Codes
%EDITFLT(numeric-expression) Convert to floating point
%EDITW(numeric-expression : edit-word) Apply an edit word
%ELEM(data-item) Number of elements in an array, table, or multiple occurrence data structure
ELSE Else
ELSEIF{(MR)} logical-expression Else If
ENDxx increment-value End a structured group
ENDSR {return-point} End of subroutine
%EOF{(file-name)} End (or beginning) of file
%EQUAL{(file-name)} Exact match for SETLL
%ERROR Error
{EVAL{(HMR)}} assignment-statement Evaluate expression
EVALR{(MR)} assignment-statement Evaluate expression, right-adjust
EVAL-CORR{(HMR)} target = source Assign corresponding subfields from one data structure to another
EXCEPT {name} Calculation time output
EXFMT{(E)} format-name {data-structure} Write then read format
EXSR subroutine-name Invoke subroutine
FEOD{(EN)} file-name Force end of data
%FIELDS(name {: name …}) Fields to update for UPDATE
%FLOAT(expression) Convert to floating point
FOR{(MR)} index {= start}
{BY increment} {TO | DOWNTO limit}
For
FORCE file-name Force a file to be read next cycle
%FOUND{(file-name)} Record found for CHAIN, DELETE, SETGT, SETLL
%GRAPH(expression {: ccsid}) Convert to graphic
%HANDLER(proc-name : comm-area) Event handler procedure for XML-SAX or XML-INTO
%HOURS(number) Number of hours
IF{(MR)} logical-expression IF
IN{(E)} {*LOCK} data-area-name Retrieve a data area
%INT(expression)
%INTH(expression)
Convert to integer format (with optional half adjust)
ITER Iterate
%KDS(data-structure-name {: num-keys}) Key data structure
LEAVE Leave a DO group
LEAVESR Leave a subroutine
%LEN(expression) Get or set length
%LOOKUP(search-argument : array
{: start {: num-elems}})
%LOOKUPGE(search-argument : array
{: start {: num-elems}})
%LOOKUPGT(search-argument : array
{: start {: num-elems}})
%LOOKUPLE(search-argument : array
{: start {: num-elems}})
%LOOKUPLT(search-argument : array
{: start {: num-elems}})
Look up element in an array
GE = Greater or equal
GT = Greater than
LE = Less or equal
LT = Less than
%MINUTES(number) Number of minutes
MONITOR Begin a Monitor Group
%MONTHS(number) Number of months
%MSECONDS(number) Number of microseconds
NEXT{(E)} program-device file-name Specify next input for multiple-device file
%NULLIND(field) Get or set null indicator
%OCCUR(data-structure) Get or set occurrence of a data structure
ON-ERROR {exception-id1
: exception-id2…}
Begin error handling for an exception id (*FILE, *PROGRAM) or status code. See Status Codes
%OPEN(file-name) Return open file condition
OPEN{(E)} file-name Open file for processing
OTHER Otherwise select
OUT{(E)} {*LOCK} data-area-name Write a data area
%PADDR(proc-name) Get procedure address
%PARMS Number of parameters
POST{(E)} {program-device} file-name Put information into a file information data structure
READ{(EN)} file-format-name
{data-structure}
Read a record
READC{(E)} record-name
{data-structure}
Read next changed record
READE{(EHMNR)} search-argument
file-record-name {data-structure}
Read equal key
READP{(EN)} file-record-name
{data-structure}
Read prior record
READPE{(EHMNR)} search-argument
file-record-name {data-structure}
Read prior equal key
%REALLOC(pointer : length) Reallocate storage with new length
REL{(E)} program-device file-name Release program device
%REM(dividend : divisor) Integer remainder
%REPLACE(replacement : source
{:start {: length}})
Replace character string
RESET{(E)} {*NOKEY} {*ALL}
structure-variable
Set variable to initial value
RETURN{(HMR)} expression Return to caller
ROLBK{(E)} Roll back
%SCAN(search-arg : source {: start}) Scan character string
%SECONDS(number) Number of seconds
SELECT Begin a select group
SETGT{(EHMR)} search-argument
file-record-name
Set greater than
SETLL{(EHMR)} search-argument
file-record-name
Set lower limit
%SHTDN Shut down requested
%SIZE(data-item {: *ALL}) Size
SORTA array-name
SORTA %SUBARR(array-name : start
{:num-elements})
Sort array
%SQRT(numeric-expression) Square root
%STATUS{(file-name)} File or program status code. See Status Codes
%STR(pointer : length) Get or set null-terminated string
%SUBARR(array-name : start
{:num-elements})
Get or set portion of an array
%SUBDT(date : duration-code) Subset of a date, time, or timestamp
%SUBST(string : start : length) Get or set substring
TEST{(DETZ)} {format} tested-field Test date/time/timestamp. See Date Formats
%THIS Class instance for native method
%TIME({expression {: format}}) Convert to time
TIMESTAMP({expression
{:*ISO | *ISO0}})
Convert to timestamp
%TLOOKUP(search-argument : table
{: alternate-table})
%TLOOKUPGE(search-argument : table
{: alternate-table})
%TLOOKUPGT(search-argument : table
{: alternate-table})
%TLOOKUPLE(search-argument : table
{: alternate-table})
%TLOOKUPLT(search-argument : table
{: alternate-table})
Look up element in a table
GE = Greater or equal
GT = Greater than
LE = Less or equal
LT = Less than
%TRIM(string {: characters})
%TRIML(string {: characters})
%TRIMR(string {: characters})
Trim characters from a string
L = Left (leading)
R = Right (trailing)
%UCS2(expression {: ccsid}) Convert to UCS-2
UNLOCK{(E)} dtaara-record-file Unlock a data area or release a record
%UNS(expression)
%UNSH(expression)
Convert to unsigned integer format, with optional half adjust
UPDATE{(E)} file-record-name
{data-structure}
UPDATE{(E)} file-record-name
%FIELDS(name {: name …})
Modify existing record
WHEN{(MR)} logical-expression When true then select
WRITE{(E)} file-record-name {data-structure} Create new record
%XFOOT(array-expression) Sum array expression elements
%XLATE(from : to : string {: start}) Translate
%XML(document {: option-string}) Specifies XML document for XML-SAX and XML-INTO
XML-INTO{(EH)} receiver
%XML(document {: option-string})
XML-INTO{(EH)}
%HANDLER(proc-name : comm-area)
%XML(document {: option-string})
Parse XML document into a variable
XML-SAX{(E)}
%HANDLER(proc-name : comm-area)
%XML(document {: option-string})
Initiate SAX parse for XML document
%YEARS(number) Number of years

Operation Code Extenders

Extender Description
(A) Always perform a dump, even if DEBUG(*NO) is specified
(D)
  1. When used with CALLP, passes operational descriptors for parameters
  2. When used with TEST, indicates test for valid date value
(E) Turns on %Error if operation code does not complete successfully
(H) Half-adjusts (rounds) numeric expression result
(M) Expression is calculated using *MAXDIGITS default precision rules
(N)
  1. When used with file I/O operation, will not lock record
  2. When used with DEALLOC, sets pointer to *NULL
  3. When used with FEOD, does not force data to non-volatile storage
(P) Pads result with blanks or zeros
(R) Expression is calculated using *RESDECPOS precision rules
(T) Used with TEST, indicates test for valid time value
(Z) Used with TEST, indicates test for valid timestamp value

Usage Conventions for syntax tables


Index | HomePage | Programming | RPG IV | Free Format