cancel
Showing results for 
Search instead for 
Did you mean: 

Fill tree from webdynpro code

Former Member
0 Kudos

Hi masters.
I need to fill a tree.

I execute a bapi from webdynpro when i clicked a button, this bapi retrieves two internal tables.
Those Internal tables are related, so i need to pass them from  a tree.

Note: I already saw the webdynpro demo programs and one uses supply function and another is really complex.

Someone have an example in code how to fill a tree ??

The requiriment is really similar to DEMOTREE. (  but i need wothout supply functions).

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

RicardoRomero_1
Active Contributor
0 Kudos

Well, you can also use a Table with a Row Arragement to create a Tree structure.

https://wiki.scn.sap.com/wiki/display/profile/2007/09/11/Integration+of+Tree+Structure+in+a+Table+us...

Former Member
0 Kudos

Hi

Follow the below steps,

->Create nodes(for ex. Billing Head & Billing Item). Note: Item node should not be Singleton.

Below code used to fill the tree after the action

TYPES: BEGIN OF ts_vbrk,
     vbeln TYPE vbrk-vbeln,
     END OF ts_vbrk.

   TYPES: BEGIN OF ts_vbrp,
        vbeln TYPE vbeln,
         posnr TYPE posnr,
         fkimg  TYPE fkimg,
         vrkme TYPE vrkme,
     END OF ts_vbrp.

   DATA lt_vbrp TYPE TABLE OF ts_vbrp.
   DATA ls_vbrp TYPE ts_vbrp.

   DATA lt_vbrk TYPE TABLE OF ts_vbrk.
   DATA ls_vbrk TYPE ts_vbrk.

   DATA ln_head TYPE REF TO if_wd_context_node.
   DATA le_head TYPE REF TO if_wd_context_element.
   DATA lt_head TYPE wd_this->elements_bill_head.
   DATA ls_head TYPE wd_this->element_bill_head.

   DATA ln_item TYPE REF TO if_wd_context_node.
   DATA lt_item TYPE wd_this->elements_bill_item.
   DATA ls_item TYPE wd_this->element_bill_item.

   ln_head = wd_context->path_get_node( wd_this->wdctx_bill_head ).

   SELECT vbeln
     FROM vbrk
   INTO TABLE lt_vbrk
     UP TO 10 ROWS.

   IF sy-subrc EQ 0.

     SELECT vbeln posnr
       FROM vbrp
       INTO TABLE lt_vbrp
       FOR ALL ENTRIES IN lt_vbrk
       WHERE vbeln EQ lt_vbrk-vbeln.

     IF sy-subrc EQ 0.

       ln_head->bind_table( lt_vbrk ).

       LOOP AT lt_vbrk INTO ls_vbrk.

         le_head = ln_head->get_element( sy-tabix ) .
         ln_item = le_head->get_child_node( wd_this->wdctx_bill_item ).

         IF le_head IS NOT INITIAL AND ln_item IS NOT INITIAL.

           CLEAR lt_item.

           LOOP AT lt_vbrp  INTO ls_vbrp WHERE vbeln = ls_vbrk-vbeln.

             CLEAR ls_item.
             MOVE-CORRESPONDING ls_vbrp TO ls_item.

             APPEND ls_item TO lt_item.

           ENDLOOP.

           ln_item->bind_table( lt_item ).

         ENDIF.

       ENDLOOP.

     ENDIF.

   ENDIF.

Thanks & Regards

Sathishkumar Arumugam