Skip to Content
author's profile photo Former Member
Former Member

alv sorting

hi

need to sort alv data, but the entries are like header and item

means first line is of header data and if has items then

the items will be displayed starting from second line but some columns for all items

will be empty (means header data at the top line refers)

now second header data comes and then its items.

in such case how to sort the ALV basing on the header number.

while sorting all the items are going at the bottom since it has no header number in its line

and header items are coming at the top

how to sort these entries correctly

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 31, 2009 at 01:40 PM

    Hi ajay r

    Its not possible in normal ALV. Either you go for alv tree or handle the requirement programatically by writting the functionality of sort in your user command.

    Venkat.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 31, 2009 at 01:59 PM

    I didn't get your requirement properly. But if you have multiple header, then you can have a try with Block ALV, to accommodate multiple ALV in a single window, where you can sort ALV individually.

    Kuntal.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 31, 2009 at 02:08 PM

    Hi Ajay,

    It is not possible. Instead you can do like this. Add one indicator field to your alv populating internal table. for the header information, give the indicator as 'H'. Then populate the sorting filed and correspondinging item details immediately.

    I hope you need not populate the value (Sorting field value) as it is same for the line items also.

    Other wise you can even use At new statement and populate the header and line items immediately.

    In either of the ways you can do.

    Regards,

    Santosh Kumar Mukka.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 31, 2009 at 07:05 PM

    GO for Heiarrchial / tree alv.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi can u send some sample easy hierarchial alv/tree avl

      i think if i can color the text for items same as background color of alv cells then the standard sorting can be used without change

      How to color the text rather than cell coloring

  • author's profile photo Former Member
    Former Member
    Posted on Apr 01, 2009 at 06:06 AM

    Hi,

    Try this

    DATA : gt_sort TYPE slis_t_sortinfo_alv,

    wa_sort TYPE slis_sortinfo_alv.

    PERFORM fill_sort. " Filling sort of REUSE_ALV_GRID_DISPALY

    FORM fill_sort .

    wa_sort-fieldname = 'MATNR'.

    wa_sort-up = c_x.

    APPEND wa_sort TO gt_sort.

    CLEAR wa_sort.

    ENDFORM. " FILL_SORT

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = g_repid

    i_grid_title = text-012

    is_layout = wa_slis_layout

    it_sort = gt_sort[]

    it_fieldcat = gt_fieldcat[]

    i_save = 'A'

    TABLES

    t_outtab = <fs_table>

    EXCEPTIONS

    program_error = 1

    OTHERS = 2.

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 01, 2009 at 06:09 AM

    Hi try using this .

    wa_sort type lvc_s_sort,

    lt_sort type lvc_t_sort.

    wa_sort-fieldname = 'SFLAG'.

    wa_sort-subtot = 'X'.

    append wa_sort to lt_sort.

    clear wa_sort.

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.