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

ALV Subtotals calculation - Urgent

Hi All,

How can I caliculate subtotals in ALV ?

How to increase column size in alv?

Regards

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Dec 18, 2007 at 07:22 AM

    Hi,

    Refer this code

    &----


    *& Form sub_display_data

    &----


    • text

    ----


    FORM sub_display_data .

    *--To sort the output through material number

    DATA : lwa_sort TYPE slis_sortinfo_alv.

    DATA : lit_sort TYPE slis_t_sortinfo_alv.

    *--Pass the values to the table

    lwa_sort-fieldname = 'PERNR'. "Field name in o/p inttable

    lwa_sort-tabname = 'it_final2'. "Output Internal table

    lwa_sort-spos = '1'. "Sort sequence

    lwa_sort-up = 'X'. "Sort in ascending order

    lwa_sort-down = ' '. "Sort in descending order

    lwa_sort-subtot = 'X'. "Subtotal

    APPEND lwa_sort TO lit_sort.

    *--Pass the values to the table

    lwa_sort-fieldname = 'WORKDATE'. "Field name in o/p inttable

    lwa_sort-tabname = 'it_final2'. "Output Internal table

    lwa_sort-spos = '2'. "Sort sequence

    lwa_sort-up = 'X'. "Sort in ascending order

    lwa_sort-down = ' '. "Sort in descending order

    lwa_sort-subtot = ' '. "Subtotal

    APPEND lwa_sort TO lit_sort.

    *--Pass the values to the table

    lwa_sort-fieldname = 'WEKLY'. "Field name in o/p inttable

    lwa_sort-tabname = 'it_final2'. "Output Internal table

    lwa_sort-spos = '3'. "Sort sequence

    lwa_sort-up = 'X'. "Sort in ascending order

    lwa_sort-down = ' '. "Sort in descending order

    lwa_sort-subtot = ' '. "Subtotal

    APPEND lwa_sort TO lit_sort.

    wa_layout-colwidth_optimize = 'X'. to increase collumn length

    IF NOT it_final2[] IS INITIAL.

    *--Call the function module to display the ALV report

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    is_layout = wa_layout

    i_callback_program = v_repid

    it_fieldcat = it_fieldcat1[]

    i_default = c_chk

    i_save = c_save

    it_sort = lit_sort

    TABLES

    t_outtab = it_final2

    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.

    ELSE.

    *--Message No data found

    MESSAGE i888 WITH text-017.

    LEAVE LIST-PROCESSING.

    ENDIF.

    ENDFORM. " sub_display_data

    Regards,

    Prashant

    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.