[ Back ]
The original release of RPG IV included a set of built-in functions. These built-in functions were:
%ADDR, %PADDR, %SIZE, %ELEM, %SUBST, %TRIM, %TRIML, %TRIMR
In addition, under OS/400 V3R2 and V3R7 the %PARMS built-in function was introduced. Since then, several built-in functions have been added to RPG IV. The following table provides the OS/400 Version and Release that the specific built-in functions were introduced and/or enhanced.
NOTE: IBM Seems to skip-ship the RPG IV compiler. So RPG IV in V4R1, V4R3 and V4R5 have no new functionality. The next scheduled upgrade is OS/400 V5R1 in Spring 2001.
| Version Release |
Built-in Function | Parameters | Return Value Description |
|---|---|---|---|
| V3R7 | %ABS | numeric expression | Absolute value of expression |
| %ADDR | variable name | Address of variable | |
| V5R1 | %ALLOC | memory size | Pointer to the allocated storage. |
| V4R2 V4R4 |
%CHAR | graphic, date, time, timestamp, or numeric expression | Value in character data type |
| V5R1 | %CHECK | compare-value : data-to-search { : start-position } | First position in the searched-data that contains a character not in the list of the characters in the compare value. |
| V5R1 | %CHECKR | compare-value : data-to-search { : start-position } | Last position in the searched-data that contains a character not in the list of the characters in the compare value. (Search begins with the right-most character and proceeds to the left. |
| V5R1 | %DATE | { value { : date-format-code } | A date data-type value after converting the "value" to the specified date format. If no value is specified, the current system date is returned. |
| V5R1 | %DAYS | days | A duration value that can be used in an expression to add a number of days to a date value. |
| V3R7 | %DEC | numeric expression {:digits : decpos} | Value in packed numeric format. If digits and decpos are specified the result value is formatted to fit in a variable of the number of digits specified. |
| V3R7 | %DECH | numeric expression : digits : decpos | Half-adjusted value in packed numeric format. The length and decimal positions |
| V3R7 | %DECPOS | numeric expression | Number of decimal digits. |
| V5R1 | %DIFF | start-date : end-date : duration-code | Calculates the difference between two date fields. The type of difference returned is specified by the duration-code. |
| V4R4 | %DIV | Numerator : Denominator | Performs integer division and returns the quotient (result) of that division operation. |
| V3R7 | %EDITC | non-float numeric expression : edit code {:*CURSYM | *ASTFILL | currency symbol} | String representing edited value. |
| V3R7 | %EDITFLT | numeric expression | Character external display representation of float. |
| V3R7 | %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 | |
| V4R2 | %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. |
| V4R2 | %EQUAL | {file name} | '1' if the most recent SETLL (for a particular file, if specified) or LOOKUP operation found an exact match '0' otherwise. |
| V4R2 | %ERROR | '1' if the most recent operation code with extender 'E' specified resulted in an error '0' otherwise. | |
| V3R7 | %FLOAT | numeric expression | Value in float format. |
| V4R2 | %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. |
| V4R4 | %GRAPHIC | Any character value | Converts character data to double-byte character set value. |
| V5R1 | %HOURS | hours | A duration value that can be used in an expression to add a number of hours to a time value. |
| V3R7 | %INT | numeric expression | Value in integer format |
| V3R7 | %INTH | numeric expression | Half-adjusted value in integer format |
| V3R7 | %LEN | any expression |
|
| V5R1 | %LOOKUPxx | search-data : array { : start-index { : elements to search }} | An array index of the element in the array where the search-data is located. |
| V5R1 | %TLOOKUPxx | search-data : searched-table { : alternate-table } | *ON if the search is successful, otherwise *OFF. (NOTE: The indexes of the searched-table and alternate-table are set to the index of the search-data if *ON is returned.) |
| V5R1 | %MINUTES | minutes | A duration value that can be used in an expression to add a number of minutes to a time value. |
| V5R1 | %MONTHS | months | A duration value that can be used in an expression to add a number of months to a date value. |
| V5R1 | %MSECONDS | milliseconds | A duration value that can be used in an expression to add a number of milliseconds to a time value. |
| V3R7 | %NULLIND | null-capable field name | Value in indicator format representing the null indicator setting for the null-capable field. |
| V5R1 | %OCCUR | data-structure | The current occurrence of the data structure, or sets the current occurrence of the data structure |
| V4R2 | %OPEN | file name | '1' if the specified file is open '0' if the specified file is closed. Consider this built-in to be an 'Is this file open?" operation. |
| %PADDR | procedure name | Address of procedure | |
| V3R2 V3R6 |
%PARMS | Number of parameters passed to procedure | |
| V5R1 | %REALLOC | pointer : new-size | Pointer to the allocated storage. |
| V4R4 | %REM | Numerator : Denominator | Performs integer division and returns the remainder from the division operation. |
| V4R2 | %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. |
| V3R7 | %SCAN | search argument : string to be searched {:start position} | First position of search argument in string or zero, if not found. |
| V5R1 | %SECONDS | seconds | A duration value that can be used in an expression to add a number of seconds to a time value. |
| V5R1 | %SHTDN | *ON if the job is being shut down (e.g., when the PWRDWNSYS command is issued) otherwise *OFF is returned. | |
| %SIZE | variable, data structure, array, or literal {: *ALL} | Number of bytes used by variable or literal. *ALL returns the number of bytes used by all the elements of the array, or all the occurrences of the data structure. | |
| V5R1 | %SQRT | expression or value | The square root of the expression or value. |
| V4R2 | %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. |
| V3R7 | %STR | pointer{:maximum length} | Characters addressed by pointer argument up to but not including the first x'00'. |
| V5R1 | %SUBDT | date : duration-code | The extracted component of the date value. (The functional equivalent of the EXTRCT operation code.) |
| %SUBST | string:start{:length} | Substring value. If length is not specified, the substring begins with start and continues through the end of the string. | |
| V5R1 | %THIS | Used for Java integration. Returns an Object reference. | |
| V5R1 | %TIME | { value { : time-format-code } | A time data-type value after converting the "value" to the specified time format. If no value is specified, the current system time is returned. |
| V5R1 | %TIMESTAMP | {value { : *ISO | *ISO0 } | A timestamp data-type value with or without separators. |
| %TRIM | string | String with left and right blanks trimmed (removed) | |
| %TRIML | string | String with left blanks trimmed | |
| %TRIMR | string | String with right blanks trimmed | |
| V4R4 | %UCS2 | Any character value | Returns a varying length value. |
| V4R2 | %UNS | numeric expression | Value in unsigned format |
| V4R2 | %UNSH | numeric expression | Half-adjusted value in unsigned format |
| V5R1 | %XLATE | from-table : to-table : string-to-convert { : starting-position } | The converted string is returned. |
| V4R4 | %XFOOT | Array name | Cross foots (totals) all the elements in an array. |