cancel
Showing results for 
Search instead for 
Did you mean: 

context_element : Access via 'NULL' object reference not possible.

Former Member
0 Kudos

Hello,

In my component controller i populated my node. ( i am seeing the value in my view)

here the code for the population:

********************************************************

lo_context_node = wd_context->get_child_node( name = wd_this->wdctx_user_parofile_node ).

lo_context_node->bind_table( tl_habili ).

*********************************************************

I am trying now to read its values.

i tried to proceed as flowing but i am getteing : Access via 'NULL' object reference not possible

and my context_element is always initail when i debug.

*************************************************************************

context_node = wd_context->get_child_node( name = wd_this->wdctx_user_parofile_node ).

context_element = context_node->get_element( ).

context_element->get_attribute( EXPORTING name = `YSTRUCT` IMPORTING value = lv_ystruct ).

*****************************************************************************

I also tried to read it as table ( i have the right cardinality) but my table is always empty.

*************************************************************************

context_node = wd_context->get_child_node( name = wd_this->wdctx_user_parofile_node ).

context_node->get_static_attributes_table( IMPORTING table = lt_user_parofile ).

***************************************************************************

Does somebody has a clue?

i am still new at webdynpro abap.

Thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

gill367
Active Contributor
0 Kudos

Put a breakpoint at the bind statement and see whether the table is having the rows in it when you are binding it.

and as Lekha pointed out try to fetch value using index number.

but i guess that will also throw error as you are not having any elements in the node.

so check the values on the table that you are binding to the node for filling it.

thanks

sarbjeet singh

Former Member
0 Kudos

Hi,

context_node = wd_context->get_child_node( name = wd_this->wdctx_user_parofile_node ).
context_element = context_node->get_element( ).

Change to

context_node = wd_context->get_child_node( name = wd_this->wdctx_user_parofile_node ).
context_element = context_node->get_element( index = 3 ). "it will return the row at 3rd index... you need to specify the index or ther eis other method GET_LEAD_SELECTION() method of the if_wd_context_node..which returns the lead selected row..

Always try to check if the referene is bound or not to avoid such dumps

context_node = wd_context->get_child_node( name = wd_this->wdctx_user_parofile_node ).
if context_node is bound.
context_element = context_node->get_element( ).
endif.

if context_element is bound.
context_element->get_attribute( EXPORTING name = `YSTRUCT` IMPORTING value = lv_ystruct ).
endif.

Before binding the table have you checked weteher the table is empty or not. Check in debugging.

If you still see some problems, check the table sturture and the Node sturcuture that you are trying to populate to BIND TABLE method.

Regards,

Lekha.

Former Member
0 Kudos

i added the " is bound " check.

it is my context_element iwch is is not bound.

i don't andrestand why.

i am using this method with all my obects and it works.

do you know why my context_element is not bount<?

Former Member
0 Kudos

Hi,

Iit is always a best pratice tp check if the references are bound or not intiiall...

they are not bound....when there is no data that is required to create that object reference..might be some pre-requisties / mandatory thinds required to careate that object,

In your case, as there is no data in the table or no data in node....there are no elements..when you try to use GET_ELEMENT it doesnot know to whcih it refers..as there is no data...Hence You get the NULL reference exception.

Regards,

Lekha.

Former Member
0 Kudos

in my controler

i populate my node as following

  • GET User Profile

SELECT SINGLE *

FROM ysr_tabl_habili

INTO l_habili

WHERE nni = sy-uname

AND yfmp = 'X'.

append l_habili to tl_habili.

IF sy-subrc EQ 0.

lo_context_node = wd_context->get_child_node( name = wd_this->wdctx_user_parofile_node ).

lo_context_node->bind_table( tl_habili ).

ENDIF.

and in debugging mode my tl_habili is not empty.

Former Member
0 Kudos

i figured it.

my node was empty at the moment when i try to read it.

thanks for help.

Former Member
0 Kudos

After the BIND TABLE statement, check teh NODE has collection or not in debuggin...There might be some sturctures mismatch...

Are you useing the same sturcture for NODE and that internal table...check this...