Skip to Content
author's profile photo
Former Member

SUBTOTAL IN ALV GRID

Hi Abapers,

In ALV Grid we can calculate the Grand total for any column from the Tool bar Option . But if we want to sub total for any particular columns to display .

Like I want subtotal of GL Codes (eg Income ,Expenses, Assets ETC. ) in FI Module

Please help , if code is available better for me .

With Best Regards

Vinayak M Deosthali.



Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • author's profile photo
    Former Member
    Sep 30, 2005 at 04:29 AM

    hi,

    in the fieldcatalog set Sub_tot = 'X' for the particular field

    cheers,

    sasi

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 30, 2005 at 04:37 AM
    DATA: struct_gridsort   TYPE lvc_t_sort WITH HEADER LINE,
          i_sort_fcat    TYPE lvc_t_sort.
    IN PBO,
    PERFORM sort_outtable CHANGING i_sort_fcat.
    
    FORM sort_outtable CHANGING p_i_sort_fcat.
      struct_gridsort-fieldname = 'YEAR'.
      <b>struct_gridsort-up       = 'X'.</b> (for sorting)
     APPEND struct_gridsort TO i_sort_fcat.
      CLEAR struct_gridsort.
    
      struct_gridsort-fieldname = 'MONTH'.
      struct_gridsort-up       = 'X'.
     <b> struct_gridsort-subtot    = 'X'</b>.(SubTotal)
      APPEND struct_gridsort TO i_sort_fcat.
      CLEAR struct_gridsort.
    
    ENDFORM.                    " sort_outtable
    

    Hope this helps.

    Kindly reward points and close the thread if ur problem got solved or kindly get back.

    Add comment
    10|10000 characters needed characters exceeded

    • Do a check before sorting for the first no.'3' and then if it changes do a total here.

        struct_gridsort-fieldname = 'HKONT'.
        struct_gridsort-down      = 'X'.
        struct_gridsort-subtot    = 'X'.(SubTotal)
        APPEND struct_gridsort TO i_sort_fcat.
        CLEAR  struct_gridsort.

      OR If possible try to find some options in lvc_t_sort.

  • author's profile photo
    Former Member
    Sep 30, 2005 at 04:45 AM

    You can use the following

    ls_sort-subtot = 'X'.

    You have to set the subtotal in the sort calatlogue.

    This is done in Sort Catalogue because you have to define the subtotal for a particular field.

    For Example,

    DATA : ls_sort type slis_sortinfo_alv.

    CLEAR ls_sort.

    ls_sort-spos = 1.

    ls_sort-fieldname = 'KUNNR'.

    ls_sort-subtot = 'X'.

    APPEND ls_sort TO lt_sort.

    Regards,

    Baburaj

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 30, 2005 at 05:12 AM

    Hi,

    Try this,

    DATA: ls_sort TYPE slis_sortinfo_alv.

    ls_sort-fieldname = 'CARRID'.

    ls_sort-spos = 1.

    ls_sort-up = 'X'.

    <b>ls_sort-subtot = 'X'.</b>

    APPEND ls_sort TO l_sort.

    Thanks&Regards,

    Ruthra.R

    Add comment
    10|10000 characters needed characters exceeded