Sign in

docs RPG Reference

Data Types Supported by Expression Operands

Data Types Supported by Expression Operands

Table 1 describes the type of operand allowed for each unary operator and the type of the result. Table 2 describes the type of operands allowed for each binary operator and the type of the result. Table 3 describes the type of operands allowed for each built-in function and the type of the result. Prototyped procedures support whatever data types are defined in the prototype definition.

Table 1. Types Supported for Unary Operations

OperationOperand TypeResult Type
- (negation)NumericNumeric
+NumericNumeric
NOTIndicatorIndicator

Table 2. Operands Supported for Binary Operations

OperatorOperand 1 TypeOperand 2 TypeResult Type
+ (addition)NumericNumericNumeric
+ (addition)DateDurationDate
+ (addition)TimeDurationTime
+ (addition)TimestampDurationTimestamp
- (subtraction)NumericNumericNumeric
- (subtraction)DateDurationDate
- (subtraction)TimeDurationTime
- (subtraction)TimestampDurationTimestamp
* (multiplication)NumericNumericNumeric
/ (division)NumericNumericNumeric
** (exponentiation)NumericNumericNumeric
+ (concatenation)Character, Graphic, UCS-2Character, Graphic, UCS-2Character, Graphic, UCS-2
+ (add offset to pointer)Basing PointerNumericBasing Pointer
- (subtract pointers)Basing PointerBasing PointerNumeric
- (subtract offset from pointer)Basing PointerNumericBasing Pointer
Note: For the following operations the operands may be of any type, but the two operands must be of the same type.
= (equal to)AnyAnyIndicator
>= (greater than or equal to)AnyAnyIndicator
> (greater than)AnyAnyIndicator
<= (less than or equal to)AnyAnyIndicator
< (less than)AnyAnyIndicator
<> (not equal to)AnyAnyIndicator
AND (logical and)IndicatorIndicatorIndicator
OR (logical or)IndicatorIndicatorIndicator
INAnyArray of any type, or %LISTIndicator

Table 3. Types Supported for Built-in Functions

OperationOperandsResult Type
%ABSNumericNumeric
%ALLOCNumericPointer
%BITANDCharacter:character{:character…}Character
%BITANDNumeric:numeric{:numeric…}Numeric
%BITNOTCharacterCharacter
%BITNOTNumericNumeric
%BITORCharacter:character{:character…}Character
%BITORNumeric:numeric{:numeric…}Numeric
%BITXORCharacter:characterCharacter
%BITXORNumeric:numericNumeric
%CHARCharacter, Graphic, UCS-2 {: ccsid }Varying length character with specified CCSID
%CHARNumericVarying length character with job CCSID
%CHARDate, Time or Timestamp {: Format of Date, Time, or Timestamp}Varying length character with job CCSID
%CHARCOUNTCharacter, Graphic, or UCS-2Numeric
%CHECKCharacter, Graphic, or UCS-2 {: Numeric}Numeric
%CHECKRCharacter, Graphic, or UCS-2 {: Numeric}Numeric
%CONCATCharacter, Graphic, or UCS-2 : Character, Graphic, or UCS-2 : …Character, Graphic, or UCS-2
%CONCATARRCharacter, Graphic, or UCS-2 : Character, Graphic, or UCS-2Character, Graphic, or UCS-2
%DATE{Character, Numeric, or Timestamp {: Date Format}}Date
%DAYSNumericNumeric (duration)
%DECCharacter : Numeric constant : Numeric constantNumeric (packed)
%DECNumeric {: Numeric constant : Numeric constant}Numeric (packed)
%DECDate, time or timestamp {: format}Numeric (packed)
%DECHCharacter : Numeric constant : Numeric constantNumeric (packed)
%DECHNumeric : Numeric constant : Numeric constantNumeric (packed)
%DECPOSNumericNumeric (unsigned)
%DIFFDate, Time, or Timestamp : Date, Time, or Timestamp : Unit {: Fractional-seconds}Numeric (duration) (compatible with both)
%DIVNumeric : NumericNumeric
%EDITCNon-float Numeric : Character Constant of Length 1 {:*CURSYM*ASTFILL
%EDITFLTNumericCharacter (fixed length)
%EDITWNon-float Numeric : Character ConstantCharacter (fixed length)
%EOF{File name}Indicator
%EQUAL{File name}Indicator
%ERRORIndicator
%FLOATCharacterNumeric (float)
%FLOATNumericNumeric (float)
%FOUND{File name}Indicator
%GRAPHCharacter, Graphic, or UCS-2 {: ccsid}Graphic with specified CCSID
%HOURSNumericNumeric (duration)
%INTCharacterNumeric (integer)
%INTNumericNumeric (integer)
%INTHCharacterNumeric (integer)
%INTHNumericNumeric (integer)
%LENAnyNumeric (unsigned)
%LISTAny { : Any { : Any …}Array (the type depends on the operands)
%LOOKUPxxAny : Any array {: Numeric {: Numeric}}Numeric (unsigned)
%LOWERCharacter : {: Numeric {: Numeric}}Character
%LOWERUCS-2 : {: Numeric {: Numeric}}UCS-2
%MAXAny : Any { : Any …}Any (depends on operands)
%MAXARRAny array {: Numeric {: Numeric}}Numeric
%MINAny : Any { : Any …}Any (depends on operands)
%MINARRAny array {: Numeric {: Numeric}}Numeric
%MINUTESNumericNumeric (duration)
%MONTHSNumericNumeric (duration)
%MSECONDSNumericNumeric (duration)
%OCCURMultiple Occurrence Data StructureMultiple Occurrence Data Structure
%OPENFile nameIndicator
%PARMSNumeric (integer)
%REALLOCPointer : NumericPointer
%REMNumeric : NumericNumeric
%REPLACECharacter : Character {: Numeric {: Numeric}}Character
%REPLACEGraphic : Graphic {: Numeric {: Numeric}}Graphic
%REPLACEUCS-2 : UCS-2 {: Numeric {: Numeric}}UCS-2
%SCANCharacter : Character {: Numeric {: Length}}Numeric
%SCANGraphic : Graphic {: Numeric {: Length}}Numeric
%SCANUCS-2 : UCS-2 {: Numeric {: Length}}Numeric
%SCANRCharacter : Character {: Numeric {: Length}}Numeric
%SCANRGraphic : Graphic {: Numeric {: Length}}Numeric
%SCANRUCS-2 : UCS-2 {: Numeric {: Length}}Numeric
%SCANRPLCharacter : Character : Character {: Numeric {: Numeric}}Character
%SCANRPLGraphic : Graphic : Graphic {: Numeric {: Numeric}}Graphic
%SCANRPLUCS-2 : UCS-2 : UCS-2 {: Numeric {: Numeric}}UCS-2
%SECONDSNumericNumeric (duration)
%SHTDNIndicator
%SPLITCharacter : {: Character }Character array
%SPLITGraphic : {: Graphic }Graphic array
%SPLITUCS-2 : {: UCS-2 }UCS-2 array
%SQRTNumericNumeric
%STATUS{File name}Numeric (zoned decimal)
%STRBasing Pointer {: Numeric}Character
Note: When %STR appears on the left-hand side of an expression, the second operand is required.
%SUBARRAny: Numeric {:Numeric}Any (same type as first operand)
%SUBDTDate, Time, or Timestamp : UnitNumeric (unsigned)
%SUBDTDate, Time, or Timestamp : Unit : Digits { : Fractional-seconds }Numeric (packed decimal)
%SUBSTCharacter : Numeric {: Numeric}Character
%SUBSTGraphic : Numeric {: Numeric}Graphic
%SUBSTUCS-2 : Numeric {: Numeric}UCS-2
%THISObject
%TIME{Character, Numeric, or Timestamp {: Time Format}}Time
%TIMESTAMP{Character, Numeric {: Timestamp Format { : Fractional-seconds}}}Timestamp
%TIMESTAMP{*SYS,Timestamp,Date { Fractional-seconds }}Timestamp
%TLOOKUPxxAny table: Any table {: Any}Indicator
%TRIMCharacter { : Character }Character
%TRIMGraphic { : Graphic}Graphic
%TRIMUCS-2 { : UCS-2 }UCS-2
%TRIMLCharacter { : Character }Character
%TRIMLGraphic { : Graphic}Graphic
%TRIMLUCS-2 { : UCS-2 }UCS-2
%TRIMRCharacter { : Character }Character
%TRIMRGraphic { : Graphic}Graphic
%TRIMRUCS-2 { : UCS-2 }UCS-2
%UCS2Character, Graphic, or UCS-2 {: ccsid}Varying length UCS-2 value with specified CCSID
%UNSCharacterNumeric (unsigned)
%UNSNumericNumeric (unsigned)
%UNSHCharacterNumeric (unsigned)
%UNSHNumericNumeric (unsigned)
%UPPERCharacter : {: Numeric {: Numeric}}Character
%UPPERUCS-2 : {: Numeric {: Numeric}}UCS-2
%XFOOTNumericNumeric
%XLATECharacter, Graphic, or UCS-2 : Character, Graphic, or UCS-2 : Character, Graphic, or UCS-2 {: Numeric}Character, Graphic, or UCS-2
%YEARSNumericNumeric (duration)
Note: For the following built-in functions, arguments must be literals, named constants or variables.
%PADDRCharacterProcedure or prototype pointer
%SIZEAny {: *ALL}Numeric (unsigned)
Note: For the following built-in functions, arguments must be variables. However, if an array index is specified, it may be any valid numeric expression.
%ADDRAnyBasing pointer
%ELEMAnyNumeric (unsigned)
%NULLINDAnyIndicator
Note: The following built-in functions are not true built-in functions in that they do not return a value. They are used in some free-form operations.
%FIELDSAny{: Any {: Any …}Not Applicable
%GENCharacter or procedure pointer { : Any}Not Applicable
%HANDLERPrototype name : AnyNot Applicable
%KDSData structure {: numeric }Not Applicable
%PARSERCharacter or procedure pointer { : Any}Not Applicable
%RANGEAny { : Any}Not Applicable
%XMLCharacter or UCS-2 { : Character }Not Applicable