cancel
Showing results for 
Search instead for 
Did you mean: 

bind_element raising exception node already bound

Former Member
0 Kudos

Hi,

ive got 3 context nodes with the same attributes.

based on the action on on node.. i want to copy the elements to one of the other two nodes

i am doing a loop after get_elements

doing my tests and after that i want to bind_element with lo_element on one of the two context nodes already bound

but than it raises the exception ..


  lo_vbeln_break_fail_node    = lo_parent_node->get_child_node( 'VBELN_BREAK_SUCCESS' ).
  lo_vbeln_break_success_node = lo_parent_node->get_child_node( 'VBELN_BREAK_FAIL' ).


  lo_selected_vbeln_node = lo_parent_node->get_child_node( 'SELECTED_VBELN' ).
  it_child_elements = lo_selected_vbeln_node->get_elements( ).

  LOOP AT it_child_elements INTO lo_child_element.

    TRY .
.....
     
CATCH cx_root INTO lo_cx_root.

        lo_vbeln_break_fail_node->bind_element( EXPORTING new_item = lo_child_element
                                                          set_initial_elements = abap_true ).

        CONTINUE.
    ENDTRY. 

    lo_vbeln_break_success_node->bind_element( EXPORTING new_item = lo_child_element
                                                         set_initial_elements = abap_true ).
  ENDLOOP.

Accepted Solutions (1)

Accepted Solutions (1)

Madhu2004
Active Contributor
0 Kudos

HI,

You are binding the elemnt of the main node to other nodes, this will raise exception as the element will have reference to the main node.

In the loop get the attributes from the main node and based on the condition create element for the other nodes and set the attributes

to the new element and bind this element.

Element can be created using the create_element method os if_wd_context_node.

Regards,

Madhu

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Adrian,

You have tried this...

bind_element( EXPORTING new_item = lo_child_element

set_initial_elements = abap_true ).

new_item of type DATA is a generic definition and hence does not return any compile time error. In general new_item referes to a internal table.

if you want to set the element, try bind_element( EXPORTING element = <parent_element> set_initial_elements = abap_true ).

Best regards,

Chinnu

Former Member
0 Kudos

Hi Adrian,

Can you post the error log you get?

Best regards,

Chinnu

Former Member
0 Kudos

Well.

if did it with set_static_attributes now.

error log was something like node already bound while trying to bind_element().

"UNCAUGHT_EXCEPTION" "CX_WD_CONTEXT"

"CL_WDR_CONTEXT_NODE_VAL=======CP" bzw.

"CL_WDR_CONTEXT_NODE_VAL=======CM005"

"INSERT_ELEMENT_ELEMENT_REF"

Former Member
0 Kudos

hi,

based on the condition, u can use the set_attribute method to set the attribute of the particular context node to a value.

regards,

Amit

Former Member
0 Kudos

hmm ok,

thought i could easily bind the already perfect element to some other context since i dont have to change anything in the element.

well .. its just a get_static_attributes and bind_structure