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

Subtotals in ALV Printing incorrectly

Hi all,

I am displaying data using alv grid. 3 column in the alv are used as for the addditon of the field's data now. next 3 column are used as average of the row values of the respective cloumn column..

Now when I click on printpreview button of ALV-grid..then it doesn't show the data in the way that was shown in alv_grid.

Just analyse the data..

data: shown in alv_grid is

column1 column2 column3 column4 column5 column6

1 2 3 4 5 6

1 2 3 4 5 6

1 2 3 4 5 6

sum1 3 6 9 4 5 6

sum2 3 6 9 4 5 6

sum3 3 6 9 4 5 6

last 3 columns(column4 column5 column6) are sorted as for taking averages

now when i click on printpreview of alv_grid to display it in alv_list

data will be displayed as following which is different from alv_grid.

column1 column2 column3 column4 column5 column6

1 2 3 4 5 6

1 2 3 4 5 6

1 2 3 4 5 6

sum1 3 6 9 12 15 18

sum2 3 6 9 4 5 6

sum3 3 6 9 4 5 6

when I am debugging the code for the above requirement then for the second and third level of sub-totals citeria is being displayed but for first level criteria is not displayed in the method_subtotal_text.

Please suggest me for the above..

Regards,

Puneet Mehta

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 09:20 AM

    Hi

    SUBTOTAL is the TOTAL at perticluar level.

    TOTAL means TOTAL of all the lines.

    LIKE:

    N1 100

    N1 200

    N2 100

    N2 500

    Subtotal

    N1 300

    N2 600

    Total

    • 900

    To get the SUBTOTAL in the ALV you need to use the SORT tables.

    In the SORT table you can find a parameter SUB_TOT. Just pass 'X' on which you want to have an subtotal. Like in the about example FLD .. pass 'X' to SUB_TOT,

    To get the TOTAL .. pass FCAT-DO_SUM = 'X' for the amount fields.

    . b]How do I add subtotals

    http://www.sapfans.com/forums/viewtopic.php?t=20386

    http://www.sapfans.com/forums/viewtopic.php?t=85191

    http://www.sapfans.com/forums/viewtopic.php?t=88401

    http://www.sapfans.com/forums/viewtopic.php?t=17335

    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_basic.htm

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 09:25 AM

    Hi Puneet,

    See below the code for ALV in which i am making total for the netprices.Just Run this program and you will get to know wat to do.

    See this stmt in fieldcatalog :lf_fieldcat-do_sum = 'X'.

    Reward if useful.

    Thkx.

    tables:ekpo.

    *data itab_ekpo type ekpo occurs 100 with header line.

    types: begin of itab_new,

    ebeln type ekpo-ebeln,

    matnr type ekpo-matnr,

    netpr type ekpo-netpr,

    end of itab_new.

    data itab1 TYPE STANDARD TABLE OF itab_new initial size 0.

    type-pools: slis.

    DATA: lt_fieldcat TYPE slis_t_fieldcat_alv, lf_fieldcat TYPE slis_fieldcat_alv.

    DATA: ws_repid TYPE sy-repid VALUE 'ZHALV2'.

    selection-screen Begin of block block1 with frame title text-111.

    select-options : S_EBELN for EKPO-EBELN.

    selection-screen end of block block1.

    INITIALIZATION.

    start-of-selection.

    select ebeln matnr netpr from ekpo into table itab1 up to 10 rows WHERE EBELN IN S_EBELN.

    PERFORM build_fieldcatalog.

    PERFORM GET_DETAILS.

    end-of-selection.

    &----


    *& Form build_fieldcatalog

    &----


    • text

    ----


    FORM build_fieldcatalog .

    • PURCHASING DOCUMENT NUMBER

    CLEAR lf_fieldcat.

    lf_fieldcat-fieldname = 'EBELN'.

    lf_fieldcat-ref_tabname = 'EKKO'.

    lf_fieldcat-ref_fieldname = 'EBELN'.

    APPEND lf_fieldcat TO lt_fieldcat.

    • MATERIAL NUMBER

    CLEAR lf_fieldcat.

    lf_fieldcat-fieldname = 'MATNR'.

    lf_fieldcat-ref_tabname = 'EKPO'.

    lf_fieldcat-ref_fieldname = 'MATNR'.

    APPEND lf_fieldcat TO lt_fieldcat.

    • NET PRICE IN PURCHASING DOCUMENT

    CLEAR lf_fieldcat.

    lf_fieldcat-fieldname = 'NETPR'.

    lf_fieldcat-ref_tabname = 'EKPO'.

    lf_fieldcat-ref_fieldname = 'NETPR'.

    *lf_fieldcat-cfieldname = 'WAERS'.

    lf_fieldcat-do_sum = 'X'.

    APPEND lf_fieldcat TO lt_fieldcat.

    ENDFORM. " build_fieldcatalog

    &----


    *& Form GET_DETAILS

    &----


    • text

    ----


    FORM GET_DETAILS.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = ws_repid

    IT_FIELDCAT = lt_fieldcat

    TABLES

    T_OUTTAB = itab1

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2.

    .

    IF SY-SUBRC <> 0.

    WRITE: 'SY-SUBRC: ', SY-SUBRC .

    ENDIF.

    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.