Skip to Content
avatar image
Former Member

Subnode table webdynpro abap

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 24, 2010 at 12:22 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.

  • avatar image
    Former Member
    Sep 24, 2010 at 12:09 PM

    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  ).

    Add comment
    10|10000 characters needed characters exceeded