cancel
Showing results for 
Search instead for 
Did you mean: 

Subnode table webdynpro abap

Former Member
0 Kudos

Hi all ,

I ve declared a node1 (0..n) in the controller in which i ve involved an other sunode (0..n) and others attributes (1..1).

node1:

-


| node2 (0..n):

-


| attributes (1..1)

-


| attribute_1 (1..1)

-


| attribute_2 (1..1)

-


| Other attributes ... (1..1)

when i add one record_1 on the node in orther to be displayed on a table it's work fine, but when i try to add an other record ->

the sub node of record_1 is lost.

I use this code to add a record to the display table:



 " bind table with only attributes (1..1) filled

bind_table( new_items = lt_node1 set_initial_elements = abap_true ).

  DATA index_table TYPE i.

  DESCRIBE TABLE lt_node1 LINES index_table.

  DATA lo_nd_node2 TYPE REF TO if_wd_context_node.

  DATA lt_node2 TYPE wd_this->elements_node2.

  lo_nd_node2 = wd_context->path_get_node( path = `NODE1.NODE2` ).

  lr_element = lo_nd_node1->get_element( index_table ).

  lo_nd_node2 = lr_element->get_child_node( 'NODE2' ).

" Bind the subnode node2  of the current index of the table node1

  lo_nd_semaines->bind_table( new_items = lt_node2 set_initial_elements = abap_true  ).
  

Any other ways of how to bind subnodes (parent and child nodes) ?

Best regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Try this way,

Create a element for node2 before you bind this way:


lo_el_node2 = lo_nd_node2->create_element( ).
lo_el_node2->set_static_attributes( static_attributes = <internal_table> ).

lo_nd_node2->BIND_ELEMENT( new_item = lo_el_node2 ).

also, clear lo_el_node2 and lo_nd_node2 so that you do not have any references to old info in them.

Best regards,

Chiinnu

Former Member
0 Kudos

Hi i resolved this by accessing by the index of the node.

But My problem now is when i want to delete the selected line -> all records of the subnodes are lost : Here is the code :



" Get all the table 

 DATA lo_nd_node1 TYPE REF TO if_wd_context_node.
 DATA lo_el_node1 TYPE REF TO if_wd_context_element.
 DATA ls_node1 TYPE wd_this->element_node1.
 DATA lt_node1 TYPE wd_this->elements_node1.
 

  lo_nd_node1= wd_context->get_child_node( name = wd_this->wdctx_node1 ).
  lo_nd_node1->get_static_attributes_table( IMPORTING table = lt_node1 ).


   "Get the selectioned line

  lo_nd_node1 = wd_context->get_child_node( name = wd_this->wdctx_node1 ).

  lo_el_node1 = lo_nd_node1->get_element( ).

  lo_el_node1->get_static_attributes(
    IMPORTING
      static_attributes = ls_node1 ).


  DELETE  TABLE lt_node1 from ls_node1.

" Bind the table
  lo_nd_node1->bind_table( new_items = lt_node1 set_initial_elements = abap_true ).

How can i solve this -> i think the subnodes are lost when i get the table and rebind it .. but i dont have any idea about how to keep them and delete the subnode of the selected line and rebind it again .

ANY idea about how to delete the selectionned line without losting the other subnodes ?

Best regards

Madhu2004
Active Contributor
0 Kudos

HI,

After getting the lement just use the REMOVE_ELEMENT method of IF_WD_CONTEXT_NODE.

"Get the selectioned line
 
  lo_nd_node1 = wd_context->get_child_node( name = wd_this->wdctx_node1 ).
 
  lo_el_node1 = lo_nd_node1->get_element( ).
 
   lo_nd_node1->remove_element(   lo_el_node1 ).

Regards,

Madhu.

Answers (1)

Answers (1)

Former Member
0 Kudos

In your last line of code where you are binding the table, the property to set the initial elemenst should be abap_false.

As shows below:

lo_nd_semaines->bind_table( new_items = lt_node2 set_initial_elements = abap_false  ).