cancel
Showing results for 
Search instead for 
Did you mean: 

About ALV as Hierarchy

Former Member
0 Kudos

I want to make my ALV like this [https://weblogs.sdn.sap.com/weblogs/images/1918/wda_alv17.jpg|https://weblogs.sdn.sap.com/weblogs/images/1918/wda_alv17.jpg] by coding. I've found a pdf about how to do it, but it doesn't work.

Here is my code:


  DATA:
        l_ref_cmp_usage TYPE REF TO if_wd_component_usage,
        l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table.

  l_ref_cmp_usage = wd_this->wd_cpuse_salv( ).
  IF l_ref_cmp_usage->has_active_component( ) is INITIAL.
    l_ref_cmp_usage->create_component( ).
  ENDIF.

  l_ref_interfacecontroller = wd_this->wd_cpifc_salv( ).
  wd_this->r_table = l_ref_interfacecontroller->get_model( ).

  cl_salv_wd_model_table_util=>if_salv_wd_table_util_stdfuncs~set_all(
    r_model = wd_this->r_table ).
  wd_this->r_table->if_salv_wd_table_settings~set_display_type(
  if_salv_wd_c_table_settings=>display_type_hierarchy ).

  DATA: lr_column TYPE REF TO cl_salv_wd_column.
  lr_column = wd_this->r_table->if_salv_wd_column_settings~get_column( 'CNOID' ).
  lr_column->if_salv_wd_column_hierarchy~set_hierarchy_column( abap_true ).
  lr_column = wd_this->r_table->if_salv_wd_column_settings~get_column( 'STOID' ).
  lr_column->if_salv_wd_column_hierarchy~set_hierarchy_column( abap_true ).

  wd_this->r_table->if_salv_wd_table_hierarchy~set_last_hier_column_as_leaf( abap_true ).

how can i make these code work?

thx

by jkchen

Accepted Solutions (1)

Accepted Solutions (1)

arjun_thakur
Active Contributor
0 Kudos

Hi Jiakai,

Refer to this [article|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c060fcb4-2c62-2b10-d2b2-f32407a5cc6f]. It explain the same thing.

I hope it helps.

Regards

Arjun

Former Member
0 Kudos

I've read this article, and my code is copied from it. But I can't understand why it doesn't work...

Former Member
0 Kudos

Thanks

Answers (2)

Answers (2)

arjun_thakur
Active Contributor
0 Kudos

Hi,

In the article there is line:


data: l_value type ref to cl_salv_wd_config_table. 

But in your code you are using

cl_salv_wd_model_table_util=>if_salv_wd_table_util_stdfuncs~set_all(
    r_model = wd_this->r_table ).

.

I have worked with the 1st statement, I am not sure if the second one has the same functionality. Just see to it. I think if you use the first statement, your problem will be solved.

Regards

Arjun

Former Member
0 Kudos

hi arjun,

it still doesn't work. when i debug it, the system sets the column hierarchy "false"...

the code is like this now:


  DATA:
        l_ref_cmp_usage TYPE REF TO if_wd_component_usage,
        l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table,
        l_value TYPE REF TO cl_salv_wd_config_table.

  l_ref_cmp_usage = wd_this->wd_cpuse_salv( ).
  IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
    l_ref_cmp_usage->create_component( ).
  ENDIF.

  l_ref_interfacecontroller = wd_this->wd_cpifc_salv( ).
  l_value = l_ref_interfacecontroller->get_model( ).

*  cl_salv_wd_model_table_util=>if_salv_wd_table_util_stdfuncs~set_all(
*    r_model = l_value ).
  l_value->if_salv_wd_std_functions~set_hierarchy_allowed( abap_true ).
  l_value->if_salv_wd_table_settings~set_display_type(
  if_salv_wd_c_table_settings=>display_type_hierarchy ).

  DATA: lr_column TYPE REF TO cl_salv_wd_column.
  lr_column = l_value->if_salv_wd_column_settings~get_column( 'CNOID' ).
  lr_column->if_salv_wd_column_hierarchy~set_hierarchy_column( abap_true ).
  lr_column = l_value->if_salv_wd_column_settings~get_column( 'STOID' ).
  lr_column->if_salv_wd_column_hierarchy~set_hierarchy_column( abap_true ).

  l_value->if_salv_wd_table_hierarchy~set_last_hier_column_as_leaf( abap_true ).

arjun_thakur
Active Contributor
0 Kudos

Hi Jiakai,

I don't think there is anything wrong with the code. Make sure that the data is getting fetched properly into the internal table and is properly binded to the node.

Arjun

Former Member
0 Kudos

hi arjun,

I create a new WD and it works finally...

but how to set the order of the hierarchy column?

pranav_nagpal2
Contributor
0 Kudos