Entering content frame

Reference Types and Reference Variables Locate the document in its SAP Library structure

You use the following syntax to define reference types:

TYPES dtype {TYPE REF TO type}|{LIKE REF TO dobj}.

The syntax for a direct declaration of a reference variable is as follows:

DATA ref {TYPE REF TO type}|{LIKE REF TO dobj}.

The addition REF TO defines a data type dtype for a reference variable and declares the reference variable ref. The specification after REF TO specifies the static type of the reference variable. The static type constricts the object set to which a reference variable can point. The dynamic type of a reference variable is the data type and the class of the object respectively, to which it currently points. The static type is always more universal or equal to the dynamic type

You can use the TYPE addition to define data types for data and object reference variables. The LIKE addition exclusively defines data types for data reference variables.

The syntax and meaning of the additions TYPE and LIKE are completely equal for both statements with the exception that TYPES creates an independent reference type, whereas DATA creates a bound reference type.

For further details and additions to this topic, see the keyword documentation.


Leaving content frame