cancel
Showing results for 
Search instead for 
Did you mean: 

Master Detail - Help me

Former Member
0 Kudos

Hi,

I'm trying to wrting to the nested node in the context but I can't.

I have the following context:

root

-


pai (1..n) singleton

-


filho(1..n) singleton

I'm tryng to do a master/detail application.

The node pai is bound to a table in my view, the node filho is bound to another. My objective is to show the detail (node filho) correct to each line in table master.

I can write to node pai, it works. I wrote to the node filho too, but when I debug, only one element of node child is filled.

If someone could help me, I would be thankfull.

The complete code is here, I put it into the wd_doinit of my view:

data: table_pai type wd_this->elements_pai,
        table_pai_linha type wd_this->element_pai,
        passo type matnr,
        lo_nd_pai type ref to if_wd_context_node,
        lo_nd_filho type ref to if_wd_context_node,
        lo_el_filho type ref to if_wd_context_element,
        table_filho_linha type wd_this->element_filho,
        lo_el_pai type ref to if_wd_context_element,
        cont type integer.

  passo = '123456789012345678'.
  
  do.

    table_pai_linha-matnr = passo.

    append table_pai_linha to table_pai.

    passo = passo + 1.

    if passo = '123456789012345683'.
      exit.
    endif.

  enddo.

  lo_nd_pai = wd_context->get_child_node( 'PAI ').

  lo_nd_pai->bind_table( new_items = table_pai set_initial_elements = abap_false ).


  cont =  lo_nd_pai->get_element_count(  ).

  do.

    lo_nd_pai->SET_LEAD_SELECTION_index( cont ).
    lo_el_pai = lo_nd_pai->get_element( ).
    lo_nd_filho = lo_el_pai->get_child_node( wd_this->wdctx_filho ).
    lo_el_filho = lo_nd_filho->create_element(  ).

    lo_nd_pai->get_attribute( exporting name = 'matnr' importing value = passo ).

    table_filho_linha-matnr_filho = passo.
    lo_el_filho->set_static_attributes(
      exporting
      static_attributes = table_filho_linha ).
    lo_nd_filho->bind_element( new_item = lo_el_filho set_initial_elements = abap_false ).

    cont = cont - 1.

    if cont = 0.
      exit.
    endif.

  enddo.

thanks,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

remove the singleton property of your node

Former Member
0 Kudos

Yogesh,

I removed the property singleton of the nodes and now it is working.

When I check them as singleton, I lost the data that I put into the elements of the node filho, only the last keeps.

Why does it happens?

Thanks for helping

Edited by: Jorge Castro on Sep 18, 2008 2:43 PM

Former Member
Former Member
0 Kudos

Yogesh,

I read the article.

So, If I set the node "filho" as singleton I can't fill this node with elements for all elements of node "pai".

The elements will be lost. It is that I don't understand, if the elements will be lost, there are no reason to use singleton, I can't imagine when I could use this option.

If I want to fill all the context in one time, I have to set the node as non-singleton.

Is all that I said correct?

sorry for the quantity of questions, but I'm new in WD4Abap and I want to learn very much.

Thanks a lot

Former Member
0 Kudos

Jorge, that's exactly the way it is.

Singletons make sense if one has huge amounts of data and doesn't want to load all that data at one time.

Former Member
0 Kudos

If I want to fill all the context in one time, I have to set the node as non-singleton.

Is all that I said correct?

Yes, if you have to fill all context then you dont use singleton property. but sometime we have to read node which contains large amount of data, in this case we can use singleton property to limit the data.

Yogesh N

Former Member
0 Kudos

Thanks a lot Yogesh and Silke.

Finally I understood how it works.

Former Member
0 Kudos

cheers

Yogesh N

Answers (0)