cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting alv in webdynpro

former_member210804
Active Participant
0 Kudos

Hi experts ,

Precisely I would like to share 2 screenshots .

1. My output

2. Required output.

1.

2.

Kindly let me know how to achieve this.

Best regards,

Narasimha.

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor

Hi,

You can group the values and sort using interface IF_SALV_WD_SORT (implementing class CL_SALV_WD_FIELD)

use method SET_GROUPING_ALLOWED.

You can refer this thread for code snippet: http://scn.sap.com/thread/1609584

Pass abap_true to method SET_GROUPING_ALLOWED to group the values.

Hope this helps u.,

Regards,

Kiran

former_member210804
Active Participant
0 Kudos

Hi Kiran,

I have applied the following code.

DATA: lo_field TYPE REF TO CL_SALV_WD_FIELD.


CREATE OBJECT lo_field
   EXPORTING
     fieldname = 'PERNR'
     .

CALL METHOD lo_field->if_salv_wd_sort~set_grouping_allowed
   EXPORTING
     value  = ABAP_TRUE
     .

On click of header of  PERNR column, that column gets sorted .

but If i comment the above code and run again , same sorting happening.

and i cant able to sort more than one column.

Please clarify my doubts.

Best regards,

Narasimha


former_member184578
Active Contributor
0 Kudos

Hi,

Use SET_MULTI_COLUMN_SORT method IF_SALV_WD_TABLE_SETTINGS (implementing class CL_SALV_WD_CONFIG_TABLE) to enable multiple coulmns sort.

Try this code

DATA lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.    

DATA lr_field TYPE REF TO cl_salv_wd_field.

DATA lo_config_model TYPE REF TO cl_salv_wd_config_table.

  lr_salv_wd_table = wd_this->wd_cpifc_alv( ).

  lo_config_model = lr_salv_wd_table->get_model( ).

  lo_config_model->if_salv_wd_table_settings~set_multi_column_sort( value = abap_true ).

  lr_field = lo_config_model->if_salv_wd_field_settings~get_field( 'PERNR' ).

  lr_field->if_salv_wd_sort~create_sort_rule( sort_order = if_salv_wd_c_sort=>sort_order_ascending ).

  lr_field->if_salv_wd_sort~set_grouping_allowed( value = abap_true ).

Regards,

Kiran

Answers (0)