Skip to Content
avatar image
Former Member

How to sort more than one column in ALV by using OO object model

Hi all,

gr_sorts = gr_table->get_sorts( ).

gr_sorts->add_sort( columnname = 'Material' subtotal = abap_true ).

The above code sorts only one column.

May I know how to sort more than one column by using OO Object model.

Thanks,

Bala Raja

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Aug 21, 2007 at 12:04 AM

    Hi,

    Try this way

    
    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[].
    
    
    
    

    aRs

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 21, 2007 at 12:02 AM

    Sure, you should be able to just add another sort, using the same method.

    gr_sorts = gr_table->get_sorts( ).
    gr_sorts->add_sort( columnname = 'MATERIAL' subtotal = abap_true ).
    gr_sorts->add_sort( columnname = 'PLANT' ).

    Regards,

    Rich Heilman

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 26, 2009 at 12:08 PM

    thanks Rich.

    Add comment
    10|10000 characters needed characters exceeded