cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot remove context node

former_member185943
Participant
0 Kudos

Hi!

I have 2 views and I navigate forth and back. On the second view I am creating a context node dynamically in method HANDLEFROM_INPUT_VIEW. Everything works fine for the first time. However, if I go back from the second view to the first one and then again navigate to the second view, the system attempts to create the new node with the same name like the existing one and I get a short dump (an exception cx_wd_context=>child_already_exist).

I tried to delete the existing node by using the below code, which I placed in methods WDDOINIT, HANDLEFROM_INPUT_VIEW (before creating the node), ONACTIONBACK and WDDOINIT, but it didn't help. What can I do?

  DATA: lr_info    TYPE REF TO if_wd_context_node_info.
* delete existing node (if there is one)
  TRY.
    lr_info = wd_context->get_node_info( ).
    lr_info = lr_info->get_child_node( 'DB_TABLE' ).
    lr_info = lr_info->get_parent( ).
    lr_info->remove_child_node( 'DB_TABLE' ).
  CATCH cx_root.
  ENDTRY.

Thanks in advance!

KR,

Igor

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Please try this way.

Before using the REMOVE_CHILD_NODE try to use the INVALIDATE method of the if_wd_context_node for removing the reference to the child node then go for deleting the child node.

Also, check for the child node is initial or not. Then invalidate it then delete the node.

Regards,

Lekha.

former_member185943
Participant
0 Kudos

Hi, Lekha,

I tried with no success. I debugged it and saw a strange result. Here is the new code:

TRY.
    lr_node = me->wd_context->get_child_node( 'DB_TABLE' ).
    lr_node->invalidate( ).
    lr_info = me->wd_context->get_node_info( ).
    lr_info = lr_info->get_child_node( 'DB_TABLE' ). "test to see is there such node
    lr_info = lr_info->get_parent( ).
    lr_info->remove_child_node( 'DB_TABLE' ).
  CATCH cx_root INTO lr_error.
    l_error_text = lr_error->get_text( ).
  ENDTRY.

lr_info object seems consistent in debugger, lr_info->get_child_node( 'DB_TABLE' ). returns a valid object, but later the statement lr_info->remove_child_node( 'DB_TABLE' ). fires exception which says: Static Node ZTEST_COMPONENT#OUTPUT_VIEW.CONTEXT Cannot Be Deleted. But I am trying to remove 'DB_TABLE'. Why am I getting message as if I was trying to delete the entire context?

KR,

Igor

Answers (1)

Answers (1)

former_member185943
Participant
0 Kudos

I forgot to pass parameter IS_STATIC when I was creating it in the first place:

lr_info->add_new_child_node(

EXPORTING static_element_type = l_tabname

name = 'DB_TABLE'

is_static = abap_false ).

Thanks for effort!

KR,

Igor