cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Proplem with reading recursive node of table tree Webdynpro ABAP

former_member187651
Active Participant
0 Kudos
1,241

Dear Gurus,

I have implemented table tree with recursive node for context in my webdynpro ABAP application. Now I am getting problem with reading the context value with event 'ONSELECT' on table. I need to refresh my ALV with  value of node attribute.

When I am trying to read the value of context attribute it always gives me parent attribute value not child attribute value. I am really stuck on this point. I have even search on SCN but did not found any satisfactory answer.

I am using following method to make my multilevel table tree:

  http://www.divulgesap.com/blog.php?p=Nzg=
http://divulgesap.com/blog.php?p=ODQ=

My Context Node is :

Please let help on this. Any suggestion is helpful to me.  

  1. Thanks..
View Entire Topic
Former Member
0 Kudos

Hi Chandan,

You cannot get the Child context values directly when ever it is a tree or multilevel.

When ever you are trying to read the value of child attribute then first you have to get the Parent context and using that Parent get the attributes of the Child context as shown in below example code.

DATA: lo_el_level1  TYPE REF TO if_wd_context_element,

         lo_nd_level2  TYPE REF TO if_wd_context_node,

         ls_level2     TYPE wd_this->element_level2,

         lt_level2     TYPE wd_this->elements_level2,

         lv_index      TYPE i.

   lo_el_level1 = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).

   IF  lo_el_level1 IS NOT INITIAL.

     lo_el_level1->get_static_attributes( IMPORTING static_attributes = ls_level2 ).

     lo_nd_level2 = lo_el_level1->get_node( ).

     lo_nd_level2->get_static_attributes_tableIMPORTING  table = lt_level2  ).

endif.

Hope this helps you.

Thanks

Phani

former_member187651
Active Participant
0 Kudos

Hello Phani,

Thanks for your reply. I need to read the attribute 'BUKID' of my context with every click.

I am using auto generated code to read the node. When I read the node with code below:

Here I am using your code like

DATA lo_nd_bucketlist TYPE REF TO if_wd_context_node.
   DATA lo_nd_bucketlist2 TYPE REF TO if_wd_context_node.
   DATA lo_el_bucketlist TYPE REF TO if_wd_context_element.
   DATA ls_bucketlist TYPE wd_this->Element_bucketlist.

  data ls_bucketlist2  TYPE wd_this->element_bucketlist.

  data lt_bucketlist2     TYPE wd_this->elements_bucketlist.

   data       lv_index      TYPE i.

* navigate from <CONTEXT> to <BUCKETLIST> via lead selection
   lo_nd_bucketlist = wd_context->get_child_node( name = wd_this->wdctx_bucketlist ).

* get element via lead selection
   lo_el_bucketlist = lo_nd_bucketlist->get_element( ).
* get all declared attributes
   lo_el_bucketlist->get_static_attributes(
     IMPORTING
       static_attributes = ls_bucketlist ).

****************************************************************************
    lo_el_bucketlist = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
    IF 
lo_el_bucketlist IS NOT INITIAL.
      lo_el_bucketlist->get_static_attributes( IMPORTING static_attributes = ls_bucketlist2 ).
      lo_nd_bucketlist2 = lo_el_bucketlist->get_node( ).
      lo_nd_bucketlist2->get_static_attributes_tableIMPORTING  table = lt_bucketlist2  ).
endif.

Now It fills the Is_bucketlist with value of parent level (1st level) with level 1.

And  lo_el_bucketlist is always null here. and your If condition is fails always......

Please tell me know where I am wrong.....

Its urgent .....



former_member187651
Active Participant
0 Kudos

when I am writting just your code:

DATA: lo_el_level1  TYPE REF TO if_wd_context_element,
           lo_nd_level2  TYPE REF TO if_wd_context_node,
           ls_level2     TYPE wd_this->element_bucketlist,
           lt_level2     TYPE wd_this->elements_bucketlist,
           lv_index      TYPE i.
     lo_el_level1 = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
 
    IF  lo_el_level1 IS NOT INITIAL.
       lo_el_level1->get_static_attributes( IMPORTING static_attributes = ls_level2 ).
       lo_nd_level2 = lo_el_level1->get_node( ).
       lo_nd_level2->get_static_attributes_tableIMPORTING  table = lt_level2  ).
  endif.

I am always getting   "lo_el_level1" blank or null.

Please let know what to do now.....

anoop_gupta2
Participant
0 Kudos

Hello Chandan ,

You can solve this problem very easily ,

All you need to do is make the Buketlist node(Parent ) cardinality as :  0 - 1 and on select event of the table / tree you can read the attribute value .

Please make sure that you call correct event . dont call you method on lead select rather call it on select .accordingly . 

former_member187651
Active Participant
0 Kudos

Hello Anoop, thanks for your reply. I have tried as you suggested but got error, as Cardinality Violation(run time error). This error is because I am Binding Node Buckelist with Internal table in the supply function for node Bucketlist. As code given below:

DATA lv_bukid           TYPE zcpm_bucket-bukid.
   DATA w_bucket          LIKE LINE OF wd_this->t_bucket.
   DATA wa_bucketlist      TYPE wd_this->element_bucketlist.
   DATA lt_bucketlist      LIKE TABLE OF wa_bucketlist.

* Get the parent bucket for which the children are requested
* In the first pass, the variable lv_bukid will be blank
* then populate level 01 bucket
     parent_element->get_attribute( EXPORTING name = 'bukid'
                                    IMPORTING value = lv_bukid ).

*******************Assigning value to Global variable bid *************************
*    CLEAR WD_THIS->BID .
*    WD_THIS->BID = LV_BUKID .
******************************************************************


       IF lv_bukid IS NOT INITIAL.
* Get all children for the parent node
     LOOP AT wd_this->t_bucket INTO w_bucket
       WHERE prntb = lv_bukid.
       MOVE-CORRESPONDING w_bucket TO wa_bucketlist.
* If the child territory has got no child then make it a leaf
       READ TABLE wd_this->t_bucket TRANSPORTING NO FIELDS
       WITH KEY prntb = w_bucket-bukid.
       IF sy-subrc <> 0.
         wa_bucketlist-is_leaf = abap_true.
       ENDIF.
* For levels 01, 02 open the nodes by default
***      if wa_bucketlist-levl eq '01' or
***         wa_bucketlist-levl eq '02'.
***        wa_bucketlist-expanded = abap_true.
***      endif.
       APPEND wa_bucketlist TO lt_bucketlist.
       CLEAR wa_bucketlist.
     ENDLOOP.
   ELSE. "Executed only in the first pass
   LOOP AT wd_this->t_bucket INTO w_bucket WHERE levl = '01'.

*    READ TABLE wd_this->t_bucket WITH KEY levl = '01'
*    INTO w_bucket.
     IF sy-subrc EQ 0.
       MOVE-CORRESPONDING w_bucket TO wa_bucketlist.
*       wa_bucketlist-expanded = abap_true.
       APPEND wa_bucketlist TO lt_bucketlist.
       CLEAR wa_bucketlist.
     ENDIF.
     ENDLOOP.
   ENDIF.


   node->bind_table( lt_bucketlist ).

Internal table T_bucket getting fillled in WDDOINIT method of Component controller when application loaded at first time.

I need to get value of Bukid on select of table each time.......

I have even tried with debug in the supply function of Bucketlist, but found this Suply function get called just first time, we used to select/Expand the bucket value, Second time this Supply Fuction do no call......

Please let me know if any doubt with issue...

Please help its urgent to me....