DATA

Variant 1

DATA f.


Addition:

... TYPE REF TO cif

Effect

Data object f is declared as reference variable within ABAP objects. cif is a class or an interface. Reference variables contain references (pointers) to objects.

Reference variables whose types are defined with reference to a class can contain references to objects of this class. Reference variables whose types are defined with reference to an intterface can contain references to objects whose class implements the interface.

Note

Objects, i.e.instances of classes, are only addressed with their reference variables. To create objects see CREATE OBJECT.

Example

INTERFACE i1.
  METHODS m1.
ENDINTERFACE.

CLASS c1 DEFINITION.
  PUBLIC SECTION.
    INTERFACES i1.
ENDCLASS.

CLASS c1 IMPLEMENTATION.
  METHOD i1~m1.
    ...
  ENDMETHOD.
ENDCLASS.

DATA: o1 TYPE REF TO c1,
      o2 TYPE REF TO c1,
      ir TYPE REF TO i1.

START-OF-SELECTION.

CREATE OBJECT o1.

o2 = o1.
ir = o1.

Additional help

Handling of Objects

Related

CLASS

PUBLIC SECTION

PROTECTED SECTION

PRIVATE SECTION

ENDCLASS

CLASS-DATA

CLASS-METHODS

CLASS-EVENTS

METHODS

EVENTS

INTERFACES

ALIASES

METHOD

ENDMETHOD

INTERFACE

ENDINTERFACE

CREATE OBJECT

CALL METHOD

RAISE EVENT

SET HANDLER

Special variants of other keywords