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: 

accessing protected method from class CL_GUI_ALV_TREE

Former Member
0 Kudos

Hi,

I have delveloped tree report using class CL_GUI_ALV_TREE.

I want to access a method CALCULATE_SUBTREE in that class.But it was protected method implemented in

super class CL_ALV_TREE_BASE class.

How to access this mehtod?

I created a local class inheriting the suprecalss and inside that i am accessing CALCULATE_SUBTREE .

But inside the mehtod the table values mt_outtab-> is initial.It gives the terinimation with access null reference.

Pleae let me know how do i access the values from the base class.

6 REPLIES 6

Former Member
0 Kudos

Hi,

     Did you try type casting to access the method in the base class? Try the below code.

     DATA : l_base TYPE REF TO cl_alv_tree_base,

                 l_tree TYPE REF TO cl_gui_alv_tree.

     /*after the required objects are created*/

     l_base ?= l_tree.

     l_base->calculate_subtree().

     I didn't try to execute the code myself. See if you can get any  help from it.

Hope this helps,

~Athreya

0 Kudos

Hi,

Thanks for the reply.

I have tried that too.

But it is showing syntax error access to protected CALCULATE_SUBTREE is not allowed.

Thanks ,

Balachandran R

0 Kudos

You can only access protected methods/attributes of super-classes from sub-classes. Casting won't be able of any help

@Bala - Can you please explain what exactly you want to achieve (your business requirement, maybe) by calling this protected method?

BR,

Suhas    

Message was edited by: Suhas Saha

0 Kudos

Hi,

The output columns are aggregated with totals.My requirement is to get the calculated line of the sub tree and comparing totals with another sub tree in the program.

Regards,

Balachandran R

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

This message was moderated.