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

Subtotals in alv-list

I am displaying an alv-list using REUSE_ALV_HIERSEQ_LIST_DISPLAY.

In the list there are two fields which are to be multiplied and shown as a subtotal under one field like as shown below:

field1 field2

1 1

2 2

____________________________________

subtotal: 5(11 + 22)

____________________________________

Can you suggest a way to display subtotals in this manner.

Thanks for your suggestions,

VB

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Oct 27, 2006 at 03:58 AM

    have a look at this example:

    &----


    *& Report ZNRW_ALV_BLOCK *

    *& *

    &----


    *& *

    *& *

    &----


    REPORT ZNRW_ALV_BLOCK .

    type-pools: slis.

    data : NUM1 type I,

    NUM type I.

    types:

    begin of str,

    mat like mara-matnr,

    client like mara-mandt,

    weight like mara-BRGEW,

    end of str.

    data

    tab type standard table of str.

    data :W_EVENT type slis_alv_event ,

    tab2 like standard table of W_EVENT,

    W_LAYOUT type slis_layout_alv,

    W_FCAT type line of slis_t_fieldcat_alv,

    tab1 like standard table of W_FCAT.

    W_FCAT-reptext_ddic = 'Mat Number'.

    W_FCAT-fieldname = 'MAT'.

    W_FCAT-tabname = 'TAB'.

    W_FCAT-ref_fieldname = 'MATNR'.

    W_FCAT-ref_tabname = 'MARA'.

    W_FCAT-seltext_l = 'MATERIAL'.

    append W_FCAT to tab1.

    W_FCAT-reptext_ddic = 'Client Num'.

    W_FCAT-fieldname = 'CLIENT'.

    W_FCAT-tabname = 'TAB'.

    W_FCAT-ref_fieldname = 'MANDT'.

    W_FCAT-ref_tabname = 'MARA'.

    W_FCAT-seltext_l = 'CLIENT'.

    W_FCAT-OUTPUTLEN = 20.

    append W_FCAT to tab1.

    W_FCAT-reptext_ddic = 'Weight'.

    W_FCAT-fieldname = 'WEIGHT'.

    W_FCAT-tabname = 'TAB'.

    W_FCAT-ref_fieldname = 'BRGEW'.

    W_FCAT-ref_tabname = 'MARA'.

    W_FCAT-seltext_l = 'weight'.

    <b>W_FCAT-DO_SUM = 'X'.</b>

    append W_FCAT to tab1.

    • W_LAYOUT-no_colhead = 'X'.

    W_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.

    W_EVENT-FORM = 'WRITE_TOP_PAGE'.

    APPEND W_EVENT TO tab2.

    NUM = 0.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

    EXPORTING

    I_CALLBACK_PROGRAM = sy-cprog.

    DATA tabDREF TYPE REF TO DATA.

    FIELD-SYMBOLS <tab> TYPE table.

    DATA IT_SORT TYPE SLIS_T_SORTINFO_ALV.

    DATA X_SORT LIKE LINE OF IT_SORT.

    *-To sort internal table based on Field Name

    CLEAR X_SORT.

    X_SORT-FIELDNAME = 'CLIENT'.

    <b>X_SORT-SUBTOT = 'X'.</b>

    X_SORT-SPOS = 1.

    X_SORT-UP = 'X'.

    APPEND X_SORT TO IT_SORT.

    do 2 times.

    CREATE DATA tabdref TYPE table of str.

    ASSIGN tabDREF->* TO <tab>.

    NUM1 = NUM1 + 10.

    refresh: tab.

    select mandt AS CLIENT matnr AS MAT BRGEW AS WEIGHT up to NUM1 rows from

    mara into

    CORRESPONDING FIELDS OF table <tab>.

    W_LAYOUT-SUBTOTALS_TEXT = 'NEILS TOTS which '."any bigger will hide text

    W_LAYOUT-TOTALS_TEXT = 'biggy TOTalS'.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

    IS_LAYOUT = W_LAYOUT

    IT_FIELDCAT = tab1

    IT_SORT = IT_SORT

    I_TABNAME = 'TAB'

    IT_EVENTS = tab2

    TABLES

    T_OUTTAB = <tab>.

    enddo.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.

    FORM WRITE_TOP_PAGE.

    NUM = NUM + 1.

    WRITE: / ,

    / 'TABLE NUMBER :', NUM.

    ENDFORM.

    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.