Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8620

Accessing the public attributes of singleton class in reports directly by object's reference

$
0
0

Hi,

 

I am new to ABAP. I know the importance and creation of singleton class. I have created one singleton class with one public  member  num1 and executed successfully.

Now in the report i have the following code

 

REPORT  zsingleton_cl.

 

DATA: lo_obj TYPE REF TO zsingleton.

 

lo_obj zsingleton=>get_instance_of( ).

 

IF lo_obj IS BOUND.

         WRITE 'object bound'.

  else.

          WRITE'object not bounded'.

ENDIF.

 

WRITE lo_obj->num1.

-------------------------------------------------------------------------------------------------------------

In report i am able to get the reference of the singleton class object and can access methods defined in the singleton class, but unable to access public attribute that is num1 of singleton class in report using the object of that class , in the last line above shown.

 

Is there any restriction in accessing public attributes of singleton class in report by its object, or is there any way to access public members of singleton class by its object except accessing attributed within the methods of that class.

 

Thanks,


Viewing all articles
Browse latest Browse all 8620

Trending Articles