cancel
Showing results for 
Search instead for 
Did you mean: 

Access via NULL reference object not possible

Former Member
0 Kudos

Hi friends,

I have created an wda application which uses the table popin to display data.

So that i have created a view with two of the fields as link to action UI element.

In the Events/Actions of the link to action element i implemented the following logic.

data wd_table_cell_editor type ref to cl_Wd_view_element.

data wd_table_column type ref to cl_wd_table_column.

data wd_popin type ref to cl_wd_table_popin.

data id type string.

<b> wd_table_cell_editor ?= wd_this->m_view->get_element( id ).</b>

wd_table_column ?= wd_table_cell_editor->get__parent( ).

wd_popin = wd_table_column->get_popin( ).

context_element->set_attribute( name = 'SELECTED_POPIN' value =

wd_popin->id ).

So when i click on the link to action in the table column of the field am getting the following error

<b>Access via NULL reference object not possible.</b>

While debugging i have noticed that this error was coming at the below step of the code.

<b>wd_table_cell_editor ?= wd_this->m_view->get_element( id )</b>

in the m_view->get_element( id ) does not contan any value , its showing as table , as null value cannnot be assigned may be its throwing the above error.

But i didnt understand why the view is not getting UI element id ....

Can one please suggest me where might be the wrong....

Regards

Sireesha.

Accepted Solutions (0)

Answers (2)

Answers (2)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi sireesha

If the line is giving this error, then m_view is null

Just check where are you setting m_view

Regards

Abhimanyu L

Former Member
0 Kudos

Hi Sireesha,

Doing a get_element will not return you the table cell editor, as it is directly not an element in your view. Instead, you can do a get_element to get the table reference. Then do a get_column and use the method get_table_cell_editor in the column class if you want the cell editor reference.

Regards

Nithya

Former Member
0 Kudos

Hi nithya,

In the get_element am passing id as a parameter so it will return the table cell editor id , here which would be the id of link to action element...

after getting the cell editor id then am getting table column and popin id's respectively, as given below

wd_table_cell_editor ?= wd_this->m_view->get_element( id ).

wd_table_column ?= wd_table_cell_editor->get__parent( ).

wd_popin = wd_table_column->get_popin( )

But in the first step itself its throwing error bcoz m_view->get_element( id ) is null...

Where the view is getting null am unable to find out.

i have defined view in the attributes as if_wd_view.

Please suggest me what could be missing?

Regards

Sireesha.

Former Member
0 Kudos

Hi Sireesha,

Where are you setting the attribute m_view? Just check whether this attribute is set before you get to the statement giving the error.

Regards,

Neha

<i><b>PS:Reward if helpful</b></i>

Former Member
0 Kudos

Where are you initializing the view reference? You should be initializing it in the modifyview method. You can do it as below:

if first_time = 'X'.

wd_this->m_view = view.

endif.

Then use the reference in your method, it should work.

regards

nithya

Former Member
0 Kudos

Nithya,

I have initialized the view reference in the modifyview itself. Now the problem is m_view is holding the class path but its not assigning the value of wd_this->m_view->get_element( id ) to wd_cell_editor.

As m_view is initialized and not null it should assign the value to the cell_editor column.but its not happening....

Could please suggest me...........

Regards

Sireesha.

Former Member
0 Kudos

Hi Sireesha,

This is what I had mentioned in my previous post, you cannot get the reference to a table cell editor by passing the ID directly. View->get_element will work only for UI elements directly defined under the view. In case of the table cell editor, it is only the table that is the UI element and not the cell editor. The cell editor reference has to be got by getting the column and the editor from the table reference.

You do not need to get the table cell editor and then do a get parent to get the column. Instead, get the table and get the column using get_column. The code would be like this:

data: lr_table type ref to cl_wd_table,

lr_table_col type ref to cl_wd_table_column.

lr_table ?= wd_this->m_view->get_element( 'table name' ).

lr_table_col = lr_table->get_column( ID = 'column ID' ).

Then you can proceed with your code.

Regards

Nithya

Message was edited by:

Nithya S

Former Member
0 Kudos

Hi nithya,

Could you please calrify the doubts for the following q's.

1. As u said in the above post, i have changed the code to the below.

data: lr_table type ref to cl_wd_table,

lr_table_col type ref to cl_wd_table_column.

lr_table ?= wd_this->m_view->get_element( 'TABLE' ).

lr_table_col = lr_table->get_column( ID = 'TABLE_CONNECTID' ).

<b>wd_popin = lr_table_col->get_popin( ).</b>

(At the above step which is in bold , eventhough there is value in lr_table_col->get_popin , its not assigning a value to the wd_popin, throwing same error NULL etc.,)

context_element->set_attribute( name = 'SELECTED_POPIN' value =

wd_popin->id ).

2. Before changing the code suggested by u, the follwoing was the code from standard example.Its working fine in the application wdr_test_table.I have debugged the code.The value is getting assigned into wd_table_cell_editor.

The same thing i have done but its failing to assign the value. thats y its throwing null reference error. Here i have a confusion how its assigning a value and y not in the z application.am giving the code below which is in standard and my application.Please clarify these.

data wd_table_cell_editor type ref to cl_Wd_view_element.

data wd_table_column type ref to cl_wd_table_column.

data wd_popin type ref to cl_wd_table_popin.

<b>wd_table_cell_editor ?= wd_this->m_view->get_element( id ).</b>

( Note : wd_this->m_view->get_element contains value but not assigning it to the wd_table_cell_editor and same code in the standard behaving correctly like assigning the view value to the cell editor. Y this behavior, please advice me)

wd_table_column ?= wd_table_cell_editor->get__parent( ).

wd_popin = wd_table_column->get_popin( ).

context_element->set_attribute( name = 'SELECTED_POPIN' value = wd_popin->id )

Regards

Sireesha.