Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Grid with ALV Tree

hkmaradana
Active Participant
0 Kudos

Hi Experts,

I have developed one ALV report by using cl_gui_alv_grid class. I need to provide expand all & unexpand like a hierarchely node for some rows.

For example i have 10 rows in alv output and out of 10 rows i need to provide + button from 5th row. When user click on + button it should show remaing 5 records. If they click again it should hide 5 rows.

Can any one suggest how to acheive this.

Thanks

Cris

5 REPLIES 5

rejish_balakrishnan
Contributor
0 Kudos

Hi,

Intially display only 5 rows and after wards when user click on EXPAND flush the alv grid list and show remaining records.(IN THIS CASE RELOAD ALV GRID WITH 10 ROWS) Do the reverse for COLLAPSE button also.

let me know if u need more help !

0 Kudos

Hi

Can you explain me how the tree structure can be obtained using object oriented menthod in alv.

For me, material and plant should be disaplyed and all other details should come under that.

Regards

Reshma

0 Kudos

Hi All,

Thanks for all your inputs, I have resolved in different way.

Solution: provided + sign in first column and prepared required records in buffer table. When user clickc on + sign read this buffer table and inserted, similarly when minimize deleted from main output table.

Problem resolved..

Thanks

Cris

MarcinPciak
Active Contributor
0 Kudos

Hi,

To do this, use rather hierarchical ALV than the usual one. Class cl_gui_alv_grid doesn't provide such functionality, whereas cl_salv_hierseq_table does. Example of the usage below:


  DATA: gt_sflight TYPE TABLE OF sflight,
           gt_scarr   TYPE TABLE OF scarr.

  DATA: ref_table TYPE REF TO cl_salv_hierseq_table.

  "set relationship between tables
  DATA: lt_relat TYPE salv_t_hierseq_binding,
           wa_relat TYPE salv_s_hierseq_binding.

  wa_relat-master = 'CARRID'.
  wa_relat-slave  = 'CARRID'.
  APPEND wa_relat TO lt_relat.

  "select data
  SELECT * FROM: sflight INTO TABLE gt_sflight UP TO 5 ROWS,
                 scarr   INTO TABLE gt_scarr   UP TO 5 ROWS.
 
  TRY.
      cl_salv_hierseq_table=>factory(
       EXPORTING
        t_binding_level1_level2 = lt_relat
       IMPORTING
        r_hierseq               = ref_table
       CHANGING
        t_table_level1          = gt_scarr
        t_table_level2          = gt_sflight ).
    CATCH cx_salv_data_error .
    CATCH cx_salv_not_found .
  ENDTRY.

  ref_table->display( ).

Regards

Marcin

Former Member
0 Kudos

Hi Cris,

For that you have to refer class cl_gui_alv_tree.

Refer sap standard program BCALV_TREE_01 for your reference.

Hope it will help you.

Pratik Vora