Try OpenEdge Now
skip to main content
ABL Reference
ABL Syntax Reference : THIS-OBJECT system reference
 

THIS-OBJECT system reference

An object reference to the currently running class instance that you can optionally use to access class members defined within the current class hierarchy.

Syntax

THIS-OBJECT [ : class-member-reference ]
class-member-reference
A reference to an instance variable data member, instance property, or instance method defined within the current class hierarchy. Any variable data member cannot be defined as an array (with an EXTENT).

Example

The following code fragment shows two instance methods defined within a class, where you must qualify a call to one of them with THIS-OBJECT because its name, Display, is an ABL reserved keyword:
CLASS TestClass:

  METHOD VOID Display( ):

  END METHOD.

  METHOD VOID Foo( ):

    THIS-OBJECT:Display( ).

  END METHOD.

END CLASS.

Notes

*You can use THIS-OBJECT without a method call to pass an object reference to the currently running object instance as a parameter, or to return an object reference to itself as a method return value.
*Use of the THIS-OBJECT system reference to call instance methods that are available within the class hierarchy where they are defined is generally optional. However, you must use the THIS-OBJECT system reference to call any instance method whose name is identical to an ABL reserved keyword. The same is true if you are calling an event method on a class-defined or inherited instance event of a class whose name is identical to an ABL reserved keyword. For more information, see the Class-based method call reference entry and the Class Events Reference.
*Use of the THIS-OBJECT system reference to access instance variable data members or properties that are available within the class hierarchy where they are defined is optional. However, you must use the THIS-OBJECT system reference to access any such data member or property whose name is identical to an ABL reserved keyword. For more information, see the Class-based data member access and Class-based property access reference entry.
*You cannot use the THIS-OBJECT system reference to access a static class member.
*To invoke other constructors defined within the current class, use the THIS-OBJECT statement.

See also

Class-based method call, THIS-OBJECT statement