RPGIV @ Work

A unique site for RPG and System i Lovers

Welcome!

Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

RPG Built-In Functions Print E-mail
User Rating: / 2
PoorBest 
Written by Chamara Withanachchi   

The original release of RPG IV included a set of built-in functions. These built-in functions were:

 

RPG IV Built-In Functions Summary


Name

Arguments

Value Returned

%ABS

numeric expression

absolute value of expression

%ADDR

variable name

address of variable

%ALLOC

number of bytes to allocate

pointer to allocated storage

%CHAR

graphic, UCS-2, numeric, date, time, or timestamp expression {: date, time, or timestamp format}

value in character format

%CHECK

comparator string:string to be checked{:start position}

first position of a character that is not in the comparator string, or zero if not found

%CHECKR

comparator string:string to be checked{:start position}

last position of a character that is not in the comparator string, or zero if not found

%DATE

{value {: date format}}

the date that corresponds to the specified value, or the current system date if none is specified

%DAYS

number of days

number of days as a duration

%DEC

numeric expression {:digits:decpos}

value in packed numeric format

%DECH

numeric expression :digits:decpos

half-adjusted value in packed numeric format

%DECPOS

numeric expression

number of decimal digits

%DIFF

date or time expression: date or time expression: unit

difference between the two dates, times, or timestamps in the specified unit

%DIV

dividend: divisor

the quotient from the division of the two arguments

%EDITC

non-float numeric expression:edit code {:*CURSYM | *ASTFILL | currency symbol}

string representing edited value

%EDITFLT

numeric expression

character external display representation of float

%EDITW

non-float numeric expression:edit word

string representing edited value

%ELEM

array, table, or multiple occurrence data structure name

number of elements or occurrences

%EOF

{file name}

'1' if the most recent file input operation or write to a subfile (for a particular file, if specified) ended in an end-of-file or beginning-of-file condition

'0' otherwise

%EQUAL

{file name}

'1' if the most recent SETLL (for a particular file, if specified) or LOOKUP operation found an exact match

'0' otherwise

%ERROR

 

'1' if the most recent operation code with extender 'E' specified resulted in an error

'0' otherwise

%FLOAT

numeric expression

value in float format

%FOUND

{file name}

'1' if the most recent relevant operation (for a particular file, if specified) found a record (CHAIN, DELETE, SETGT, SETLL), an element (LOOKUP), or a match (CHECK, CHECKR, SCAN)

'0' otherwise

%GRAPH

character, graphic, or UCS-2 expression

value in graphic format

%HOURS

number of hours

number of hours as a duration

%INT

numeric expression

value in integer format

%INTH

numeric expression

half-adjusted value in integer format

%LEN

any expression

length in digits or characters

%LOOKUPxx

argument: array{:start index {:number of elements}}

array index of the matching element

%MINUTES

number of minutes

number of minutes as a duration

%MONTHS

number of months

number of months as a duration

%MSECONDS

number of microseconds

number of microseconds as a duration

%NULLIND

null-capable field name

value in indicator format representing the null indicator setting for the null-capable field

%OCCUR

multiple-occurrence data structure name

current occurrence of the multiple-occurrence data structure

%OPEN

file name

'1' if the specified file is open

'0' if the specified file is closed

%PADDR

procedure or prototype name

address of procedure or prototype

%PARMS

none

number of parameters passed to procedure

%REALLOC

pointer: numeric expression

pointer to allocated storage

%REM

dividend: divisor

the remainder from the division of the two arguments

%REPLACE

replacement string: source string {:start position {:source length to replace}}

string produced by inserting replacement string into source string, starting at start position and replacing the specified number of characters

%SCAN

search argument:string to be searched{:start position}

first position of search argument in string or zero if not found

%SECONDS

number of seconds

number of seconds as a duration

%SHTDN

 

'1' if the system operator has requested shutdown

'0' otherwise

%SIZE

variable, array, or literal {:* ALL}

size of variable or literal

%SQRT

numeric value

square root of the numeric value

%STATUS

{file name}

0 if no program or file error occurred since the most recent operation code with extender 'E' specified

most recent value set for any program or file status, if an error occurred

if a file is specified, the value returned is the most recent status for that file

%STR

pointer{:maximum length}

characters addressed by pointer argument up to but not including the first x'00'

%SUBDT

date or time expression: unit

an unsigned numeric value that contains the specified portion of the date or time value

%SUBST

string:start{:length}

substring

%THIS

 

the class instance of the native method

%TIME

{value {: time format}}

the time that corresponds to the specified value, or the current system time if none is specified

%TIMESTAMP

{(value {: timestamp format})}

the timestamp that corresponds to the specified value, or the current system timestamp if none is specified

%TLOOKUPxx

argument: search table {: alternate table}

'*ON' if there is a match

'*OFF' otherwise

%TRIM

string

string with left and right blanks trimmed

%TRIML

string

string with left blanks trimmed

%TRIMR

string

string with right blanks trimmed

%UCS2

character, graphic, or UCS-2 expression

value in UCS-2 format

%UNS

numeric expression

value in unsigned format

%UNSH

numeric expression

half-adjusted value in unsigned format

%XFOOT

array expression

sum of the elements

%XLATE

from-characters: to-characters: string {: start position}

the string with from-characters replaced by to-characters

%YEARS

number of years

number of years as a duration

<Previous   Next>