‎2007 Nov 27 7:22 AM
hello friends,
i am using the class cl_salv_table to display my ALV. now on my selection screen i have 3 radio buttons,according to the radiobutton selected my output should appear sorted.
which class can help me sort my internal fields according to the radio button on the selection screen and pls tell me how to do this.
‎2007 Nov 28 7:02 AM
Hi,
try this code for sorting for more than 2 fields
form built_sort_table.
data ls_sort_wa type lvc_s_sort.
ls_sort_wa-spos = 1.
ls_sort_wa-fieldname = 'MATNR'.
ls_sort_wa-up = selected.
ls_sort_wa-subtot = ''.
append ls_sort_wa to gt_sort.
ls_sort_wa-spos = 2.
ls_sort_wa-fieldname = 'STATUS'.
ls_sort_wa-up = selected.
ls_sort_wa-subtot = ''.
append ls_sort_wa to gt_sort.
endform.
then
call method grid1->set_table_for_first_display
exporting
it_list_commentary = gt_header[]
is_layout = gs_layout_tree
changing
it_sort = gt_sort[]
it_outtab = gt_yitm[]
it_fieldcatalog = gt_fieldcat_lvc[].
Hope this might be helpful to u.
Regards,
MS.
‎2007 Nov 28 7:06 AM
Hi,
Check this...
DATA: lr_sorts TYPE REF TO cl_salv_sorts.
DATA: lr_agg TYPE REF TO cl_salv_aggregations.
TRY.
lr_sorts = gr_table->get_sorts( ).
lr_sorts->add_sort( columnname = 'FIELD1' subtotal = gc_true ).
lr_sorts->add_sort( columnname = 'FIELD2' subtotal = gc_true ).
lr_sorts->add_sort( columnname = 'FIELD3' subtotal = gc_true ). "subtotal is optional for each field
etc
CATCH cx_salv_existing. "#EC NO_HANDLER
CATCH cx_salv_not_found. "#EC NO_HANDLER
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.
TRY.
lr_agg = gr_table->get_aggregations( ).
lr_agg->add_aggregation( 'FIELD4' ).
lr_agg->add_aggregation( 'FIELD5' ).
etc
CATCH cx_salv_existing. "#EC NO_HANDLER
CATCH cx_salv_not_found. "#EC NO_HANDLER
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.Regards,
Omkar.