You define a variable for a class is similar to how you define a variable for a procedure. The main difference is in the access mode you specify for the variable.

Here is the simplified ABL syntax to define a variable data member:

 define access-mode variable variable-name as type-name [no-undo].
Syntax Element

Description

access-mode

Specifies whether the data member will be available to other parts of an application. As a best practice, you should define as PRIVATE or PROTECTED. For more information, see Access modes.

variable-name

Must begin with a letter and it can contain letters, numbers, underscores, or hyphens. It must not contain periods or spaces.

type-name

Can be one of the ABL data types such as integer or character or it can be a user-defined type.

no-undo

No-undo is recommended for all variable definitions, regardless of where they are used. If you use no-undo, the value of the variable is not restored to its original value in the event of a transaction rollback. You rarely need this capability so it is recommended that you use no-undo as it is more efficient at runtime.

Here is a variable data member defined for the Dept class. Every instance of a Dept class will hold its own values for this data member. Since this data member is PRIVATE, it will be accessible only by the methods of this class.

class Enterprise.HR.Dept: 
//used for keeping track of how many employees are in the set of employees
//for the department used internally within the class. 

  define public property NumEmployee as integer no-undo. 

  // rest of class definition 

end class.

For more information, see DEFINE VARIABLE statement and Local variables and other data elements of methods.