Skip to Content
author's profile photo
Former Member

To activate total & subtotal button in ALV by class

Hi,

Kindly suggest how to activate total & subtotal button in ALV by class. I have used layout configuration by lvc_s_layo.

gs_layout type lvc_s_layo.

Ashutosh Kumar

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • author's profile photo
    Former Member
    Oct 04, 2005 at 09:12 AM

    Switch on the DO_SUM field in the field catalog for the specific field you want to show the totals.

    Regards,

    Ravi

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 04, 2005 at 09:12 AM

    Hi

    I think they are automatically actived if your output table have numeric fields, for this field set flag DO_SUM in catalog table

    Max

    Message was edited by: max bianchi

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 04, 2005 at 09:15 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
    
    
    <b>Fieldcatalog type lvc_s_layo</b>.
    For Total u can do in the <b>fieldcatalog</b> 
    there will be an option <b>DO_SUM make that 
    to 'X'</b> for the column name u want to do so.
    
    

    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

  • author's profile photo
    Former Member
    Oct 04, 2005 at 09:17 AM

    Hi Ashutosh,

    Welcome to SDN.

    did you said table for first display......

    like this

    call method g_grid->set_table_for_first_display
        EXPORTING
          it_toolbar_excluding = lt_exclude
          it_hyperlink         = gt_hypetab
          is_layout            = gs_layout
        CHANGING
          it_fieldcatalog      = pt_fieldcat
          it_outtab            = pt_outtab.

    hope this helps you.

    check these links it may help you

    http://help.sap.com/saphelp_erp2004/helpdata/en/ef/a2e9e9f88311d2b48d006094192fe3/frameset.htm

    http://help.sap.com/saphelp_erp2004/helpdata/en/fa/efb52cf8a611d2b48d006094192fe3/frameset.htm

    reward points for helpfull answers and close the thread if your question is solved.

    regards,

    venu.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 04, 2005 at 09:30 AM

    Dears,

    Do_SUM is not available in gs_layout type lvc_s_layo.

    Its working only in function module REUSE_ALV_LIST_DISPLAY.

    How to use in class ALV.

    FORM SUB_CREATE_FIELDCATALOG .

    • THIS BELOW FIELD IS EDITABLE

    PERFORM APPEND_FIELDCAT USING:'MATNR'

    'Material No.'

    'CHAR'

    '30'

    ' '

    ' '.

    PERFORM APPEND_FIELDCAT USING:'MATKL'

    'DOCUMENT TYPE'

    'CHAR'

    '10'

    ' '

    ' '.

    PERFORM APPEND_FIELDCAT USING:''

    ''

    'CHAR'

    '4'

    'C610'

    ' '.

    PERFORM APPEND_FIELDCAT USING:'NTGEW'

    'NET WT'

    'P'

    '10'

    'C610'

    'X'.

    PERFORM APPEND_FIELDCAT USING:'VOLTO'

    'VOLUME'

    'P'

    '10'

    'C610'

    'X'.

    PERFORM APPEND_FIELDCAT USING:'VPREH'

    'COST'

    'P'

    '10'

    'C610'

    ' '.

    ENDFORM. " SUB_CREATE_FIELDCATALOG

    &----


    *& FORM APPEND_FIELDCAT

    &----


    • TEXT

    ----


    • -->P_0116 TEXT

    • -->P_0117 TEXT

    • -->P_0118 TEXT

    • -->P_0119 TEXT

    • -->P_0120 TEXT

    • -->P_10 TEXT

    ----


    FORM APPEND_FIELDCAT USING P_114

    P_115

    P_116

    P_117

    P_118

    P_119.

    CLEAR GT_FIELDCAT_LVC.

    GT_FIELDCAT_LVC-FIELDNAME = P_114.

    GT_FIELDCAT_LVC-COLTEXT = P_115.

    GT_FIELDCAT_LVC-DATATYPE = P_116.

    GT_FIELDCAT_LVC-OUTPUTLEN = P_117.

    GT_FIELDCAT_LVC-EMPHASIZE = P_118.

    GT_FIELDCAT_LVC-do_sum = P_119.

    append gt_fieldcat_lvc.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      U can use

      <b>

      NO_TOTLINE = ' '.

      </b>

      This is the option available in LVC_S_LAYO.

      U can do as below for summing

      In PBO of the screen

          PERFORM f9001_build_field_cat TABLES i_fieldcat
                                  USING 'MARC'.
      *   Modifying the field catalog
          PERFORM f9002_modify_field_cat TABLES i_fieldcat.
      *   For Layout
          PERFORM f9003_layout USING sy-title 'X' 'B' 'X' .
      *   To display output
          PERFORM f9004_display_data TABLES i_output
                                            i_fieldcat.
      
      FORM f9002_modify_field_cat TABLES p_fieldcat STRUCTURE lvc_s_fcat.
       c_x = 'X'.
      <b>  FIELD-SYMBOLS : <lfs_fieldcat> TYPE lvc_s_fcat.</b>
      
        LOOP AT p_fieldcat ASSIGNING <lfs_fieldcat>.
          CASE <lfs_fieldcat>-fieldname.
            WHEN 'MATNR'.
              <lfs_fieldcat>-coltext = text-009.
              <lfs_fieldcat>-hotspot = c_x.
      <b>        <lfs_fieldcat>-do_sum = c_x.</b>
            WHEN 'WERKS'.
              <lfs_fieldcat>-coltext = 'Plant'.
            WHEN OTHERS.
              <lfs_fieldcat>-no_out = c_x.
          ENDCASE.
        ENDLOOP.
      
      ENDFORM.                    " f9002_modify_field_cat
      
      <b> DATA:   wa_layout TYPE lvc_s_layo ,</b>
                  wa_variant TYPE disvariant.
      
      FORM f9003_layout USING  value(ptitle)
                               value(pzebra)
                               value(pmode)
                               value(pwidth).
      
        wa_layout-grid_title  = ptitle.
        wa_layout-zebra       = pzebra.
        wa_layout-sel_mode    = pmode.
        wa_layout-cwidth_opt  = pwidth.
        wa_variant-report     = sy-repid.
      ENDFORM.                    " f9003_layout
      FORM f9004_display_data TABLES   p_output
                                       p_fieldcat.
        CALL METHOD o_alvgrid->set_table_for_first_display
          EXPORTING
            is_variant                    = wa_variant
            i_save                        = c_a
      <b>      is_layout                     = wa_layout</b>
          CHANGING
            it_outtab                     = p_output[]
            it_fieldcatalog               = p_fieldcat[]
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            OTHERS                        = 4.
      
        IF sy-subrc <> 0.
          MESSAGE i000 WITH 'Error in ALV report display'.
          LEAVE LIST-PROCESSING.
        ENDIF.
      

      Hope this helps.