Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

reference variablies versus field symbols

Former Member
0 Kudos
94

hello,

can some body please explain me (with relevant proofs if any) which of the above two is best and more advantageous??

Looking forward for ur replies.

Thanks in advance.

3 REPLIES 3

Former Member
0 Kudos
69

Hi Pramod,

One quick reply to this is

Field symbol is a dereferenced pointer.

Referenced variable is a pointer.

Field symbol holds the data.

Ref. var holds the address of the data.

Using Field symbol u can not instantiate a class.

Reward points if useful,

Aleem.

Former Member
0 Kudos
69

Hi,

reference variablies -> This wil Hold the address number of the data

field symbols --> Will point to the Address number and it will hold the data

Regards

Sudheer

uwe_schieferstein
Active Contributor
0 Kudos
69

Hello Pramod

If you need a reference variable which has "field symbol" like properties simply use:


DATA:
  lo_object       TYPE REF TO object.  " root of all ABAP classes

This variable will hold instances of any ABAP class or interface.

In order to use any method you have to do the appropriate casting, e.g.:

  DATA:
    lo_class     TYPE REF TO cl_oo_class.


  CREATE OBJECT lo_object  TYPE ('CL_OO_CLASS').  " or:

  CREATE OBJECT lo_class
     EXPORTING
      ...

  lo_object = lo_class.

  lo_class ?= lo_object.  " casting
  CALL METHOD lo_class->...( ).

Regards

Uwe