Application Development and Automation 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: 
Read only

Access protected attribute from outside the class

Former Member
0 Likes
7,848

Hi All,

I have to access the protected method of the class in a badi . The class name is CL_WDR_CONTEXT_NODE_VAL and the protected attribute is TABLE_REF.

In the badi i have to get the TABLE _REF attribute value. I could not access from badi because its a protected method.

Please give some suggestions to resolve this.

Thanks,

Pradeep.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,079

Hello Pradeep,

You should use the public method IF_WD_CONTEXT_NODE~GET_STATIC_ATTRIBUTES_TABLE to return the table values. If this does not suffice and you need the nodes, you could look at other public methods such as IF_WD_CONTEXT_NODE~GET_CHILD_NODES.

Hope this helps.

Thanks,

Venkat.

Message was edited by: Venkat Gowrishankar

Hi All,

I have to access the protected method of the class in a badi . The class name is CL_WDR_CONTEXT_NODE_VAL and the protected attribute is TABLE_REF.

In the badi i have to get the TABLE _REF attribute value. I could not access from badi because its a protected method.

Please give some suggestions to resolve this.

Thanks,

Pradeep.

14 REPLIES 14
Read only

wol
Active Participant
0 Likes
4,079

You souldn´t want this

But: If the attribute is protected on your system you could inherit the class and access it there.

But on my system the attribute is private. So this does not work.

Regards,

Stefan

Read only

Former Member
0 Likes
4,079

Hi Stefan,

Yes i need that attribute in my badi . And also i have tried to inherit from super class and when i was trying to create its throwing me an error as "Super class has CREATE PRIVATE property so you cannot inherit ".

is there any way in trying by FRIENDS???

Read only

wol
Active Participant
0 Likes
4,079

Hi,

oh yes, I didn´t look for instantiation type.

The point with friends is that the SAP-Class must define her friends and it would be a modification.

I don´t see a possibility without modification / enhancement.

Regards,

Stefan

Read only

Former Member
0 Likes
4,080

Hello Pradeep,

You should use the public method IF_WD_CONTEXT_NODE~GET_STATIC_ATTRIBUTES_TABLE to return the table values. If this does not suffice and you need the nodes, you could look at other public methods such as IF_WD_CONTEXT_NODE~GET_CHILD_NODES.

Hope this helps.

Thanks,

Venkat.

Message was edited by: Venkat Gowrishankar

Read only

0 Likes
4,078

 

Hi venkat,

Actually i have used the method GET_CHILD_NODE only .

Here LO_NODE is a context node

      

  CL_WDR_CONTEXT_NODE_VAL is class

  TABLE_REF is a protected attribue and it has 2 entries as shown above. i need to access these 2 values.

Hope you understand.

Read only

0 Likes
4,078

Hello Pradeep,

You should not access the value of the node directly via its attributes , you should use the  methods in the interface IF_WD_CONTEXT_NODE. If you need to return the values for all elements in the node, you should use the method - GET_STATIC_ATTRIBUTES_TABLE ( This would return the values in a table for all the elements in the node  - Maybe the table in the screenshot you attached!). You could also loop through each element in the Node and use the method GET_STATIC_ATTRIBUTES or use GET_ATTRIBUTE of interface IF_WD_CONTEXT_ELEMENT to retrieve for a specific attribute.

http://scn.sap.com/docs/DOC-2213 - This doc explains the context and the access methods.

Hope this helps.

Thanks,

Venkat.

Read only

0 Likes
4,078

Hi ,

Please check this in SE24 and let me know.

CLASS         :         CL_WDR_CONTEXT_NODE_VAL

ATTRIBUTE :         TABLE_REF

Read only

0 Likes
4,078

Hi,

I checked it and please let me know what i need to Know .

Before asking me to check,

Have you tried calling the method which I had mentioned?, Did it not meet your requirement?. Have you looked into the code of the method  'GET_STATIC_ATTRIBUTES_TABLE'.

Have you done a where used list for that attribute?.

BTW, the attribute is Private in my system.

Thanks,

Venkat.

Read only

0 Likes
4,078

Hi Venkat,

Its works fine.. You rock!!!! Thanks a lot. But how we have to find out the correct method ??

Read only

0 Likes
4,078

Hello Pradeep,

If you work with Web dynpro ABAP contexts, you would have never posed the question .

If you had gone through the document which I had attached above, you would have got a clearer picture of how the WD4A context works and how to use the methods to retrieve the values. A general rule is that when an attribute is private or protected, always look for a public method that would be able to return that value- If there is no method, then it was never intended to be used outside of the class. Do a where used list for the attribute and see how that attribute is affected in the class and see if there is a public method which would help you to return the value.

I hope this helps.

Thanks,

Venkat.

Read only

0 Likes
4,078

Thanks Venkat .

Read only

0 Likes
4,078

Hi venkat ,

Do you have any idea about the POWL auto refresh ???

Read only

0 Likes
4,078

Hello Pradeep,

I have not worked with POWL and hence I cannot advice you on it . But from a purely conceptual view, I think you could investigate POWL config transactions ( Ex:POWL_COCKPIT,POWL_QUERY etc..) to configure the  Auto refresh functionality for a particular Query.

I am sorry , but this is the best I could do .

Thanks,

Venkat.

Read only

0 Likes
4,078

Okay .. Thanks a lot for your suggestions venkat