cancel
Showing results for 
Search instead for 
Did you mean: 

How to access private attribute of class CL_WDR_CONTEXT_NODE_VAL

Former Member
0 Kudos

Hi ,

I have created a simple webdynpro program where my application display the table entries in a table.

I have applied filter values on the table.

So for this I have created a action and it is working fine.

The problem here is I need to handle exceptions raised by the application and for this I need to acces the private variable of the class CL_WDR_CONTEXT_NODE_VAL .

I am new to OOPS and still in learning stage.

Request to guide me in how to read the private attribute of class in our webdynpro application.

Awaiting for your responses.

Thanks & Regards,

Ravi Ganji

Accepted Solutions (1)

Accepted Solutions (1)

saravanan_narayanan
Active Contributor
0 Kudos

Hello Ravi,

as SSM mentioned, you can access the private variable outside the class. its the oops concepts. Let us know what exactly you want to access in the CL_WDR_CONTEXT_NODE_VAL class and why, so that we can provide alternatives?

BR, Saravanan

Former Member
0 Kudos

Hi,

Thanks for the reply.

SSM mentioned that we can't access Private Variable but as I know using Friend Classes we can access private variable.

Anyways I will tell you my requirement..

I have main view, in that I have places three container elements.

in one container element i have displayed the selection screen

in second container element i have displayed the business graphs based on the values displayed in the table view

in third container element i have displayed the data in a table view. for this i have applied FILTER property and one action button to clear the filter values.

Now my application is working fine the only issue is to handle the exception raised the application. My applicaion is causing dump when i click on the action button in order to clear the Filter values. This is happening only when the thrid container element which consists a table to view the data in the form of table view.

I have debugged the code and I see in the debugging that the class CL_WDR_CONTEXT_NODE_VAL which has private variable "tab_ref" can be used to check whether this is initial or not before when I apply action on clearing the filter values.

This avoids the dump.

i hope I have explained clearly abt the dump.

i have checked various options but when I use it showing a dump saying that you are refering to a NULL object which is true.

Please help me how to progress on this.

Thanks & Regards,

Ravi Ganji

saravanan_narayanan
Active Contributor
0 Kudos

Hello Ravi,

in the Clear Filter method, are you trying the clear the values in the context node? If so then you check whether the context element is initial or not?

alternative - you can post your CLEAR_FILTER code then we can point you in right direction.

BR, Saravanan

Former Member
0 Kudos

Hi,

I agree what you said but if we clear the context element it giving a dump as the program is refering to the NULL reference.As I said earlier my table has no data but still I am applying Filter and then clearing the Filter node value.

It is working correct when my table is not initial.

i hope you got my point.

Please find the code below,

METHOD onactionclear_filter .

DATA: l_node TYPE REF TO if_wd_context_node. "This is context for Filter

DATA: lo_nd_nrs_status TYPE REF TO if_wd_context_node. " This is context for Table

DATA lo_api_controller TYPE REF TO if_wd_controller.

DATA lo_message_manager TYPE REF TO if_wd_message_manager.

Data clr TYPE wd_this->element_nrs_status.

DATA flg TYPE wdy_boolean.

DATA l_ele TYPE REF TO if_wd_context_element.

*data node_ele TYPE REF TO CL_WDR_CONTEXT_ELEMENT.

*data node_val TYPE REF TO CL_WDR_CONTEXT_NODE_VAL.

*data node type ref to CL_WDR_CONTEXT_NODE.

*data node_tab type WDR_CONTEXT_PROP_FOR_NODE_TAB.

l_node = wd_context->get_child_node( if_table_view=>wdctx_filter ).

  • lo_nd_nrs_status = wd_context->get_child_node( name = wd_this->wdctx_nrs_status ).

CALL METHOD l_node->get_static_attributes

IMPORTING

static_attributes = clr.

IF clr IS INITIAL.

lo_api_controller ?= wd_this->wd_get_api( ).

CALL METHOD lo_api_controller->get_message_manager

RECEIVING

message_manager = lo_message_manager .

  • report message

CALL METHOD lo_message_manager->report_error_message

EXPORTING

message_text = 'Incorrect Selection' .

EXIT.

ENDIF.

l_node->INVALIDATE( ).

ENDMETHOD.

Thanks & Regards,

Ravi Ganji

saravanan_narayanan
Active Contributor
0 Kudos

Hello Ravi,

shouldn't the type of variable clr be wd_this->element_filter?


Data clr TYPE wd_this->element_nrs_status.

"change it to
data clr type wd_this->element_filter.

and the call to l_node->get_static_attributes method will throw cx_wd_context exception if the filter node is empty. Catch this exception and proceed accordingly. If the filter node is empty its not required to call invalidate. I think you have handled it already.

Br, Saravanan

Former Member
0 Kudos

thanks Saara...it helped me!

Thanks & Regards,

Ravi Ganji

Answers (1)

Answers (1)

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

i assume that you cannot access that variable outside the class.

for more information refer

http://forums.sdn.sap.com/thread.jspa%3FthreadID%3D969131%26tstart%3D3259&sa=U&ei=-LEuTvGrPMSo8QPT0Y...

Former Member
0 Kudos

Hi ,

Thanks for the reply.

If you refer the class, it has friend classes where I can make use of friend instance to invoke the private attribute of the class CL_WDR_CONTEXT_NODE_VAL.

I hope that is what the functionality of a Friend function.

Can you check on this and update me.

Thanks & Regards,

Ravi Ganji