cancel
Showing results for 
Search instead for 
Did you mean: 

Access via 'NULL' object reference not possible.

Former Member
0 Kudos

hi ,

i am trying to set the text of a text element through coding.For that i am reading the context attribute ( using wizard ) and then stting the value = 'something'. but i am repetedly getting error like " Access via 'NULL' object reference not possible. "

DATA lo_nd_cn_lstmodify TYPE REF TO if_wd_context_node.

DATA lo_el_cn_lstmodify TYPE REF TO if_wd_context_element.

DATA ls_cn_lstmodify TYPE wd_this->element_cn_lstmodify.

DATA lv_ca_userid LIKE ls_cn_lstmodify-ca_userid.

  • navigate from <CONTEXT> to <CN_LSTMODIFY> via lead selection

lo_nd_cn_lstmodify = wd_context->get_child_node( name = wd_this->wdctx_cn_lstmodify ).

  • @TODO handle not set lead selection

IF lo_nd_cn_lstmodify IS INITIAL.

ENDIF.

  • get element via lead selection

lo_el_cn_lstmodify = lo_nd_cn_lstmodify->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_cn_lstmodify IS INITIAL.

ENDIF.

  • alternative access via index

  • lo_el_cn_lstmodify = lo_nd_cn_lstmodify->get_element( index = 1 ).

  • @TODO handle non existant child

  • IF lo_el_cn_lstmodify IS INITIAL.

  • ENDIF.

  • get single attribute

lo_el_cn_lstmodify->set_attribute(

EXPORTING

name = `CA_USERID`

value = 'hello' ).

the attribute is inside a node cn_lstmodify. please help me out.

Accepted Solutions (0)

Answers (4)

Answers (4)

Madhu2004
Active Contributor
0 Kudos

HI..

Can you go to ST22 and check where exactly it is giving dump...

Madhu

Former Member
0 Kudos
'something'. but i am repetedly getting error like " Access via 'NULL' object reference not possible. " 

lo_nd_cn_lstmodify = wd_context->get_child_node( name = wd_this->wdctx_cn_lstmodify ).

Put the break point at above line of code and check whether you are getting value into node or not.

or

check the cardinality.

or

lo_nd_cn_lstmodify = wd_context->get_child_node( name = wd_this->wdctx_cn_lstmodify ).

also write like

lo_nd_cn_lstmodify = wd_context->get_child_node( 'NODE NAME' ).

i hopw this will help you

thanks

Suman

Former Member
0 Kudos

hi,

IF lo_el_cn_lstmodify IS INITIAL.

ENDIF.

alternative access via index

lo_el_cn_lstmodify = lo_nd_cn_lstmodify->get_element( index = 1 ).

@TODO handle non existant child

IF lo_el_cn_lstmodify IS INITIAL.

ELSE.

*get single attribute

lo_el_cn_lstmodify->set_attribute(

EXPORTING

name = `CA_USERID`

value = 'hello' ).

ENDIF.

Yogesh N

Former Member
0 Kudos

Check the cardinality of your context node. If it is 0..1 or 0..n it might well contain no elements. In this case method

lo_el_cn_lstmodify = lo_nd_cn_lstmodify->get_element(  ).

will deliver null which is correct.

You might need to add an element to this node first:

  DATA lr_data_node TYPE REF TO if_wd_context_node.
  lr_data_node->bind_structure( ls_data ).

Kind regards, Silke