cancel
Showing results for 
Search instead for 
Did you mean: 

ALV TABLE - EXPAND / COLLAPSE ALL

Former Member
0 Kudos

Hey Everyone,

just wondering if there is a way to expand / collapse all elements under a hierarchy of an ALV table.

i looked around and i only found a method - expand_all - for tree structure.. under class... cl_salv_nodes.

i tried using it but i comes up with an error, Access Via Null Object Reference not possible.

thanks in advance..

Accepted Solutions (1)

Accepted Solutions (1)

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Did you do it the same way as mentioned below.

data lr_node TYPE ref TO cl_salv_nodes.

CREATE OBJECT lr_node

EXPORTING

r_controller = . "pass the value which is of type IF_SALV_CONTROLLER_METADATA

.

lr_node->expand_all( ).

Can you paste your code .

Regards,

Priya

Former Member
0 Kudos

Hey Priya, Thanks.. i tried this - ( ddnt work tho ).

-


data lr_meta type REF TO IF_SALV_CONTROLLER_METADATA.

data lr_node TYPE ref TO cl_salv_nodes.

CREATE OBJECT lr_node

EXPORTING

r_controller = lr_meta. "pass the value which is of type IF_SALV_CONTROLLER_METADATA

lr_node->expand_all( ).

-


what value are we to get from interface IF_SALV_CONTROLLER_METADATA

Former Member
0 Kudos

Finally found a way,.. so i am just sharing...

There are methods under... cl_salv_wd_config_table to expand/collapse the hierrarchy..

here is my full code for the alv, with one column set as hierrachy.. then at the end i expand all..

hope it helps...

DATA lr_node TYPE REF TO if_wd_context_node.

DATA wd_node TYPE REF TO if_wd_context_node.

DATA lr_element TYPE REF TO if_wd_context_element.

DATA lo_COMPONENTCONTROLLER TYPE REF TO IG_COMPONENTCONTROLLER .

data lr_column type ref to cl_salv_wd_column.

data lo_cmp_usage type ref to if_wd_component_usage.

lo_cmp_usage = wd_this->wd_cpuse_alv_machine_summary( ).

if lo_cmp_usage->has_active_component( ) is initial.

lo_cmp_usage->create_component( ).

endif.

DATA lo_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .

lo_INTERFACECONTROLLER = wd_this->wd_cpifc_alv_machine_summary( ).

DATA lo_value TYPE ref to cl_salv_wd_config_table.

lo_value = lo_interfacecontroller->get_model( ).

  • display type

lo_value->IF_SALV_WD_TABLE_SETTINGS~SET_DISPLAY_TYPE(

IF_SALV_WD_C_TABLE_SETTINGS=>DISPLAY_TYPE_HIERARCHY ).

*update node..

lr_column = lo_value->if_salv_wd_column_settings~get_column( 'DB2_VERSION' ).

lr_column->if_salv_wd_column_hierarchy~set_HIERARCHY_COLUMN( abap_true ).

lr_column = lo_value->if_salv_wd_column_settings~get_column( 'DB2_LEVEL' ).

lr_column->if_salv_wd_column_hierarchy~set_HIERARCHY_COLUMN( abap_false ).

lr_column = lo_value->if_salv_wd_column_settings~get_column( 'MACHINE' ).

lr_column->if_salv_wd_column_hierarchy~set_HIERARCHY_COLUMN( abap_false ).

*-----

lo_value->IF_SALV_WD_TABLE_HIERARCHY~SET_EXPANDED(

EXPORTING

VALUE = ABAP_TRUE

).

Edited by: imatari on Nov 28, 2009 6:10 AM

Edited by: imatari on Nov 28, 2009 6:10 AM

Answers (1)

Answers (1)

Former Member
0 Kudos

Look at the methods under -- cl_salv_wd_config_table ---

.......

DATA lo_value TYPE ref to cl_salv_wd_config_table.

lo_value = lo_interfacecontroller->get_model( ).

  • display type

lo_value->IF_SALV_WD_TABLE_SETTINGS~SET_DISPLAY_TYPE(

IF_SALV_WD_C_TABLE_SETTINGS=>DISPLAY_TYPE_HIERARCHY ).

*---

Set your hierrarchy columns

*---

"Expand your hierrarchy columns

lo_value->IF_SALV_WD_TABLE_HIERARCHY~SET_EXPANDED(

EXPORTING

VALUE = ABAP_TRUE

).