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

The filtering , sorting , totaling action on ALV report is lost

Hi ,

I have an Interactive ALV report which i sort it , filter it and total it before I enter into my Z customised screen, from my Z cusomised screen when I come back to the ALV report, the report is no more sorted, no more filtered and no more totaled.

Please help me on this its a bit urgent.

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 Dec 04, 2007 at 10:32 AM

    Hi Krishna,

    Welcome to SDN....

    You need to save all the functionalities sort,filter and so on with one layout name.

    To acheive the above you need to click on change layout and go to each tab in the next coming pop-up and save it with a name and you should use this layout as default or you need to execute your report with this layout.

    Cheers,

    Bujji

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 10:34 AM

    Hi

    Add Default Sorting to ALVgrid report

    In order to display an ALV report with specific columns already sorted by default you will need to build a

    sort catalogue. This is fairly straight forward and is done in the following way:

    Step 1. Add data declaration for sort catalogue

    Step 2. Add code to build sort catalogue table

    Step 3. Update 'gd_tree->set_table_for_first_display' method call to include parameter 'it_sort'

    • ALV data declarations

    data: it_sortcat type LVC_T_SORT,

    it_sortcatdb type LVC_T_SORT.

    perform build_sortcat.

    &----


    *& Form build_sortcat

    &----


    • Build Sort catalog

    ----


    FORM build_sortcat .

    wa_sort-spos = 1.

    wa_sort-fieldname = 'EBELN'.

    wa_sort-SUBTOT = 'X'. "subtotals any totals column by this field

    • gd_sortcat-tabname

    APPEND wa_sort TO it_sortcat.

    wa_sort-spos = 2.

    wa_sort-fieldname = 'EBELP'.

    • gd_sortcat-tabname

    APPEND wa_sort TO it_sortcat.

    ENDFORM. " build_sortcat

    CALL METHOD gd_tree->set_table_for_first_display

    EXPORTING

    is_layout = gd_layout

    CHANGING

    it_fieldcatalog = gd_fieldcat

    it_sort = it_sortcat

    it_outtab = it_report.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 10:35 AM

    HI

    above one is for OOP ALV

    see this

    Add Default Sorting to ALVgrid report

    In order to display an ALV report with specific columns already sorted by default you will need to build a

    sort catalogue. This is fairly straight forward and is done in the following way:

    Step 1. Add data declaration for sort catalogue

    Step 2. Add code to build sort catalogue table

    Step 3. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include parameter 'it_sort'

    • ALV data declarations

    data: it_sortcat type slis_sortinfo_alv occurs 1,

    wa_sort like line of it_sortcat.

    perform build_sortcat.

    &----


    *& Form build_sortcat

    &----


    • Build Sort catalog

    ----


    FORM build_sortcat .

    wa_sort-spos = 1.

    wa_sort-fieldname = 'EBELN'.

    wa_sort-SUBTOT = 'X'. "subtotals any totals column by this field

    • gd_sortcat-tabname

    APPEND wa_sort TO it_sortcat.

    wa_sort-spos = 2.

    wa_sort-fieldname = 'EBELP'.

    • gd_sortcat-tabname

    APPEND wa_sort TO it_sortcat.

    ENDFORM. " build_sortcat

    call function 'REUSE_ALV_GRID_DISPLAY'

    exporting

    i_callback_program = gd_repid

    i_callback_top_of_page = 'TOP-OF-PAGE'

    is_layout = gd_layout

    it_fieldcat = fieldcatalog[]

    it_sort = it_sortcat

    i_save = 'X'

    tables

    t_outtab = it_ekko

    exceptions

    program_error = 1

    others = 2.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 10:36 AM

    &----


    *& Report ZALV_SUM

    *&

    &----


    *&

    *&

    &----


    REPORT ZNNR_ALV_SUM.

    TABLES: ekko.

    type-pools: slis. "ALV Declarations

    *Data Declaration

    *----


    TYPES: BEGIN OF t_vbap,

    vbeln TYPE vbap-vbeln,

    matnr TYPE vbap-matnr,

    netwr TYPE vbap-netwr,

    waerk TYPE vbap-waerk,

    END OF t_vbap.

    DATA: it_vbap TYPE STANDARD TABLE OF t_vbap INITIAL SIZE 0,

    wa_vbap TYPE t_vbap.

    *ALV data declarations

    data: fieldcatalog type slis_t_fieldcat_alv with header line,

    gd_tab_group type slis_t_sp_group_alv,

    gd_layout type slis_layout_alv,

    gd_repid like sy-repid.

    ************************************************************************

    *Start-of-selection.

    START-OF-SELECTION.

    perform data_retrieval.

    perform build_fieldcatalog.

    perform build_layout.

    perform display_alv_report.

    &----


    *& Form BUILD_FIELDCATALOG

    &----


    • Build Fieldcatalog for ALV Report

    ----


    form build_fieldcatalog.

    fieldcatalog-fieldname = 'VBELN'.

    fieldcatalog-seltext_m = 'Sales Order'.

    fieldcatalog-col_pos = 0.

    fieldcatalog-outputlen = 10.

    fieldcatalog-emphasize = 'X'.

    fieldcatalog-key = 'X'.

    append fieldcatalog to fieldcatalog.

    clear fieldcatalog.

    fieldcatalog-fieldname = 'MATNR'.

    fieldcatalog-seltext_m = 'Material Number'.

    fieldcatalog-col_pos = 4.

    append fieldcatalog to fieldcatalog.

    clear fieldcatalog.

    fieldcatalog-fieldname = 'NETWR'.

    fieldcatalog-seltext_m = 'Net Price'.

    fieldcatalog-col_pos = 7.

    fieldcatalog-outputlen = 15.

    fieldcatalog-do_sum = 'X'. "Display column total

    fieldcatalog-cfieldname = 'WAERK'.

    append fieldcatalog to fieldcatalog.

    clear fieldcatalog.

    fieldcatalog-fieldname = 'WAERK'.

    fieldcatalog-seltext_m = 'Price Curr'.

    fieldcatalog-col_pos = 8.

    append fieldcatalog to fieldcatalog.

    clear fieldcatalog.

    endform. " BUILD_FIELDCATALOG

    &----


    *& Form BUILD_LAYOUT

    &----


    • Build layout for ALV grid report

    ----


    form build_layout.

    gd_layout-no_input = 'X'.

    gd_layout-colwidth_optimize = 'X'.

    gd_layout-totals_text = 'Totals'(201).

    • gd_layout-totals_only = 'X'.

    • gd_layout-f2code = 'DISP'. "Sets fcode for when double

    • "click(press f2)

    • gd_layout-zebra = 'X'.

    • gd_layout-group_change_edit = 'X'.

    • gd_layout-header_text = 'helllllo'.

    endform. " BUILD_LAYOUT

    &----


    *& Form DISPLAY_ALV_REPORT

    &----


    • Display report using ALV grid

    ----


    form display_alv_report.

    gd_repid = sy-repid.

    call function 'REUSE_ALV_GRID_DISPLAY'

    exporting

    i_callback_program = gd_repid

    • i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

    • i_callback_user_command = 'USER_COMMAND'

    • i_grid_title = outtext

    is_layout = gd_layout

    it_fieldcat = fieldcatalog[]

    • it_special_groups = gd_tabgroup

    • IT_EVENTS = GT_XEVENTS

    i_save = 'X'

    • is_variant = z_template

    tables

    t_outtab = it_vbap

    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.

    endform. " DISPLAY_ALV_REPORT

    &----


    *& Form DATA_RETRIEVAL

    &----


    • Retrieve data form EKPO table and populate itab it_ekko

    ----


    form data_retrieval.

    select vbeln matnr netwr waerk

    up to 50 rows

    from vbap

    into table it_vbap.

    endform. " DATA_RETRIEVAL

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 10:40 AM

    hi ,

    this sorting , filtering and totaling can be handeled by your alv program only.

    an in your case this will be the best way to dclare all these internally.

    for sorting do like this:

    FORM alv_sort_data.

    • first sort records on the basis of week

    DATA: wa_alv_sort TYPE slis_sortinfo_alv.

    wa_alv_sort-spos = 1.

    wa_alv_sort-fieldname = 'WEEK'.

    wa_alv_sort-up = 'X'.

    APPEND wa_alv_sort TO it_alv_sort.

    • second sort on the basis of date

    wa_alv_sort-spos = 2.

    wa_alv_sort-fieldname = 'DATE'.

    wa_alv_sort-up = 'X'.

    APPEND wa_alv_sort TO it_alv_sort.

    *third sort o the bais of day

    wa_alv_sort-spos = 3.

    wa_alv_sort-fieldname = 'DAY'.

    wa_alv_sort-up = 'X'.

    APPEND wa_alv_sort TO it_alv_sort.

    ENDFORM. "alv_top_of_page

    and finally pass this it_alv_sort to reuse_alv_grid

    as:

    it_sort = it_alv_sort

    ******************************************************

    for totaling do like this:

    line_fieldcat-fieldname = 'M700-01'.

    line_fieldcat-seltext_m = text-056.

    line_fieldcat-col_pos = 35.

    line_fieldcat-outputlen = 12.

    line_fieldcat-no_out = 'X'.

    <b> line_filedcat-do_sum = 'X'.</b>

    APPEND line_fieldcat TO v_fieldcatalog.

    just add do_sum under those fields for which you want to get total in your alv.

    ***************************************

    i hope this will solve your problem.

    plz reward points if helps.

    regards,

    rahul

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 11:05 AM

    Hi,

    Can you please paste your code.

    Thanks,

    Sriram Ponna.

    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.