Skip to Content
avatar image
Former Member

alv text for sub totals and grand total

Hi friends

Iam displsying a alv grid display.

now my requirement is iam displaying vendor wise subtotal and grand total for all the vendors with in a compnay code.

now i need text where ever iam displaying subtotal as

subtotal for so and so vendor.

example :

for vendor 100

subtotal for vendor 100

for vendor 200

subtotal for vendor 200

and at the last it should display text as grand total.

How can i do that.

Regards,

Priyanka.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Sep 04, 2008 at 09:33 AM

    Hi

    Check this thread

    alv-subtotals-and-grand-total-for-a-field

    Regards

    Pavan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 04, 2008 at 09:33 AM

    Hi Priyanka,

    Check the sample in this thread:

    to-get-grand-total-text-not-sub-total-text-in-alv

    Regards,

    Chandra Sekhar

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 04, 2008 at 09:37 AM

    Hi,

    For every vendor add subtotal by using

    AT NEW vendor

    grandtotal = grandtotal +subtotal.

    ENDAT.

    You can display the grand total by using SAP script at the end.

    Regards

    Mudit

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 04, 2008 at 09:51 AM

    Hi,

    In Grid Display,For printing subtotals you have to assign do_sum in fieldcat for the numeric field you are trying to get the sub-total for.

    like,

    IS_FCAT-FIELDNAME = Vendor_field.

    IS_FCAT-DO_SUM = 'X'.

    APPEND IS_FCAT TO IT_FCAT.

    For printing Grand Total,use sort and enable SUBTOT.

    Consider the following program,where sort level is at VKORG and GRANDTOTAL and SUBTOTAL at NETWR.

    TYPE-POOLS: SLIS.

    *----


    DATA DECLARE

    DATA: BEGIN OF IT_DATA OCCURS 1,

    VBELN LIKE VBRK-VBELN,

    VKORG LIKE VBRK-VKORG,

    BUKRS LIKE VBRK-BUKRS,

    KUNRG LIKE VBRK-KUNRG,

    NETWR LIKE VBRK-NETWR,

    UNITP LIKE VBRK-NETWR,

    END OF IT_DATA.

    *----


    FIELD CAT VARIABLES DECLARE

    DATA: IS_FCAT TYPE slis_fieldcat_alv,

    IT_FCAT TYPE slis_t_fieldcat_alv.

    *----


    LAYOUT DECLARATION

    DATA: IS_LAY TYPE SLIS_LAYOUT_ALV.

    *----


    SORT DECLARATION

    DATA: IS_SORT TYPE slis_sortinfo_alv,

    IT_SORT TYPE slis_t_sortinfo_alv.

    START-OF-SELECTION.

    PERFORM GET_DATA.

    PERFORM BUILD_DATA.

    PERFORM DO_SORT.

    PERFORM MOD_LAYOUT.

    PERFORM SHOW_ALV.

    &----


    *& Form GET_DATA

    &----


    FORM GET_DATA .

    SELECT VBELN VKORG BUKRS KUNRG NETWR FROM VBRK INTO TABLE IT_DATA UP TO

    15 ROWS.

    LOOP AT IT_DATA.

    IT_DATA-UNITP = IT_DATA-NETWR / 3.

    MODIFY IT_DATA.

    ENDLOOP.

    ENDFORM. " GET_DATA

    &----


    *& Form BUILD_DATA

    &----


    FORM BUILD_DATA .

    *----


    FIELD1

    IS_FCAT-FIELDNAME = 'VBELN'.

    IS_FCAT-TABNAME = 'IT_DATA'.

    IS_FCAT-SELTEXT_M = 'BILL DOC NO'.

    APPEND IS_FCAT TO IT_FCAT.

    CLEAR IS_FCAT.

    *----


    FIELD2

    IS_FCAT-FIELDNAME = 'VKORG'.

    IS_FCAT-TABNAME = 'IT_DATA'.

    IS_FCAT-SELTEXT_M = 'SALES ORG'.

    APPEND IS_FCAT TO IT_FCAT.

    CLEAR IS_FCAT.

    *----


    FIELD3

    IS_FCAT-FIELDNAME = 'BUKRS'.

    IS_FCAT-TABNAME = 'IT_DATA'.

    IS_FCAT-SELTEXT_M = 'COMPANY NO.'.

    APPEND IS_FCAT TO IT_FCAT.

    CLEAR IS_FCAT.

    *----


    FIELD4

    IS_FCAT-FIELDNAME = 'KUNRG'.

    IS_FCAT-TABNAME = 'IT_DATA'.

    IS_FCAT-SELTEXT_M = 'PAYER'.

    IS_FCAT-EMPHASIZE = 'C210'.

    APPEND IS_FCAT TO IT_FCAT.

    CLEAR IS_FCAT.

    *----


    FIELD5

    IS_FCAT-FIELDNAME = 'NETWR'.

    IS_FCAT-TABNAME = 'IT_DATA'.

    IS_FCAT-SELTEXT_M = 'NET VALUE'.

    IS_FCAT-DO_SUM = 'X'.

    "SUBTOTAL2 TO ENABLE SUM OF THIS FIELD

    APPEND IS_FCAT TO IT_FCAT.

    CLEAR IS_FCAT.

    *----


    FIELD6

    IS_FCAT-FIELDNAME = 'UNITP'.

    IS_FCAT-TABNAME = 'IT_DATA'.

    IS_FCAT-SELTEXT_M = 'UNIT PRICE'.

    APPEND IS_FCAT TO IT_FCAT.

    CLEAR IS_FCAT.

    ENDFORM. " BUILD_DATA

    &----


    *& Form SHOW_ALV

    &----


    FORM SHOW_ALV .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    IS_LAYOUT = IS_LAY

    IT_FIELDCAT = IT_FCAT

    IT_SORT = IT_SORT

    TABLES

    T_OUTTAB = IT_DATA.

    ENDFORM. " SHOW_ALV

    &----


    *& Form MOD_LAYOUT

    &----


    FORM MOD_LAYOUT .

    IS_LAY-ZEBRA = 'X'. "STRIPPED LIST

    ENDFORM. " MODIFYING_LAYOUT

    &----


    *& Form DO_SORT

    &----


    FORM DO_SORT .

    IS_SORT-FIELDNAME = 'VKORG'.

    IS_SORT-TABNAME = 'IT-DATA'.

    IS_SORT-UP = 'X'.

    IS_SORT-SUBTOT = 'X'.

    APPEND IS_SORT TO IT_SORT.

    ENDFORM. " DO_SORT

    Add comment
    10|10000 characters needed characters exceeded