cancel
Showing results for 
Search instead for 
Did you mean: 

Delete node created dynamically

RicardoRomero_1
Active Contributor
0 Kudos

Hi all,

I'm creating some nodes dynamically for create also some UI elements and do the binding.

I have also a button for "restart" the view and recreate again the nodes. But when I'm trying to delete a node I'm getting an error like:

Cannot delete ZZ_TEST#MAIN.CONTEXT.MY_NODE

I've removed all my code and I've only left the code for create the node and the code for delete it, but the error still appears.

This is my code:

DATA: lo_context_info TYPE REF TO if_wd_context_node_info,
        lo_my_node_info
TYPE REF TO if_wd_context_node_info,
        lo_nd_my_node
TYPE REF TO if_wd_context_node.

  lo_context_info = wd_context->get_node_info( ).

 
TRY.
      lo_nd_my_node = wd_context->get_child_node( name =
'MY_NODE' ).
   
CATCH cx_wd_context.

 
ENDTRY.
 
IF lo_nd_my_node IS NOT INITIAL.

    lo_nd_my_node->invalidate( ).

   
CALL METHOD lo_context_info->remove_child_node
     
EXPORTING
        name   =
'MY_NODE'.
 
ENDIF.

 
CALL METHOD lo_context_info->add_new_child_node
   
EXPORTING
      name                         =
'MY_NODE'
      is_mandatory                 = abap_true
      is_mandatory_selection       = abap_false
      is_multiple                  = abap_false
      is_multiple_selection        = abap_true
      is_singleton                 = abap_true
      is_initialize_lead_selection = abap_true
    RECEIVING
      child_node_info              = lo_my_node_info.

Do you know what i need to do?


Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ricardo,

Try passing the is_static parameter and set it as false.

Most probably the code to remove it will work after that.

Regards,

Jaspreet

RicardoRomero_1
Active Contributor
0 Kudos

Thanks Jaspreet  ! this solved my problem !

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Ricardo,

Try setting is_mandatory to false and check.

Regards,

Fareez

RicardoRomero_1
Active Contributor
0 Kudos

Hi Fareez,

I've tried setting is_mandatory to false, but the error still appears.

Former Member
0 Kudos

Hi Ricardo,

I believe the same as Jaspreet. Try adding the is_static parameter. It must work.

Regards,

Fareez

Sharathmg
Active Contributor
0 Kudos

From the code, it looks like you are trying to delete before adding the node.

Try to move the add new node code afirst and then call the delete node.

Let me know, if that resolves the issue.

Regards,

Sharath

RicardoRomero_1
Active Contributor
0 Kudos

Hi Sharath,

I'm using the same button for create the node and for the delete it.

The first time you use the button the node is not created yet, so the var lo_nd_my_node returns empty and I'm not trying to delete it. Then I'm creating the node.

The second time you push the button the node is already created. So this second time the var lo_nd_my_node is filled, and then i'm trying to delete it.