Variables and data types
- Last Updated: January 22, 2026
- 3 minute read
- OpenEdge
- Version 12.8
- Documentation
ABL lets you define program variables for use within an application. A
variable must be defined with a specific data type. A variable can be initialized with a
value when it is defined, or it can be assigned a value later. You use the
VAR statement or the DEFINE VARIABLE statement to
define variables. The VAR statement is a newer
shorthand notation for the DEFINE VARIABLE statement
that is less verbose. Most variables can be defined using the VAR statement.
Define a variable using the VAR statement
The basic simplified syntax of the VAR statement is:
|
- datatype
- Specifies the data type of the variable, for example, CHAR, INT, DECIMAL, DATE, LOGICAL. See the following table for a list of supported data types.
- varname
- Specifies the name of the variable.
- expression
- An Expression which evaluates to a data type that is consistent with the data type of the defined variable. See the Default initial values table below for a list of default initial values for each data type.
The following example code shows some variables definitions using VAR:
|
Define a variable using the DEFINE VARIABLE statement
The basic simplified syntax of the DEFINE VARIABLE statement is:
|
- varname
- Specifies the name of the variable.
- datatype
- Specifies the data type of the variable, for example, CHARACTER, INTEGER, DECIMAL, DATE, LOGICAL. See the following table for a list of supported data types.
INITIALvalue- Optionally specifies an initial value for the variable. If specified, the value must be a constant. See the following table for a list of default initial values for each data type.
EXTENTn- Optionally specifies that the variable is an array of size n. The size must be an integer. After the
array is defined, you can then reference the individual array elements in
your code by enclosing the array subscript in brackets, as in
myVar[2] = 5. NO-UNDO- Specifies that the variable does not require transaction support. The best
practice is to always use
NO-UNDOfor variables unless explicitly required, to prevent unnecessary overhead.
See Other variable qualifiers in Develop ABL Applications for more information on other qualifiers.
Data types
ABL supports a range of Data types, and each data type has a default initial value that can be overridden. The ABL data types are listed in the following table.
| Data type name | Default initial value |
|---|---|
| CHARACTER or CHAR | "" (The empty
string) |
| CLASS object-type-name | Unknown value (?) |
| DATE | Unknown value (?) |
| DATETIME | Unknown value (?) |
| DATETIME-TZ | Unknown value (?) |
| DECIMAL | 0 |
| HANDLE | Unknown value (?) |
| INTEGER or INT | 0 |
| INT64 | 0 |
| LOGICAL | no |
| LONGCHAR | Unknown value (?) |
| MEMPTR | Unknown value (?) |
| RAW | A zero-length sequence of bytes |
| ROWID | Unknown value (?) |
Assign a value to a variable
ABL assigns values to variables using the assignment statement (=). In the following example, the variable, name, is set to the string, NewCustomer.
|
See Assign a value to a variable for more information.
Compound assignment operators
ABL has compound assignment operators (+=, -=, *=, /=), which allow you to combine
addition, subtraction, multiplication, and division operators with an assignment.
See Compound assignment operators for more information.
ABL Unknown value
For certain data types, when a value is not yet assigned to the data element,
ABL associates the Unknown value with the data element. In ABL, you represent the
Unknown value with a question mark (?). Note that
you do not put quotation marks around the question mark; the question mark acts as a
special symbol on its own. The Unknown value (?)
is not equal to any defined value. In ABL, you write a statement that looks as
though you are comparing a value to a question mark, such as: IF ShipDate = ?, but the statement is asking if
ShipDate has the Unknown value, which means it
has no particular value. The Unknown value is like the NULL value in SQL, and the
expression IF ShipDate = ? is like the SQL
expression IF ShipDate IS NULL.
For more information, see Use the ABL Unknown value.