Skip to Content

Cannot remove context node

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 02:02 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

  • Posted on Jan 15, 2009 at 05:58 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.