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

ALV - Subtotals button greyed out

Hi

I have created a ALV with OO. I have added code to subtotal based on a field. The values are getting displayed properly. There is no subtotal

This is because the Subtotal Button on the ALV display is greyed out.

Any info on why it is greyed out.

There is a similar kind of report for which it is working fine. So, it is not GUI problem i guess

Here is my code

  CHECK alv_dock IS INITIAL.
  CREATE OBJECT alv_dock
    EXPORTING
      extension  = 1200
     EXCEPTIONS
       OTHERS    = 1.
  IF sy-subrc <> 0 AND sy-batch IS INITIAL.
    MESSAGE a016(pn) WITH 'Unable to create output area'(e01).
  ENDIF.

  CREATE OBJECT alv_grid
    EXPORTING
      i_parent      = alv_dock
   EXCEPTIONS
      OTHERS    = 1.
  IF sy-subrc <> 0 AND sy-batch IS INITIAL.
    MESSAGE a016(pn) WITH 'Unable to create output area'(e01).
  ENDIF.

* set layout
  wa_layout-grid_title = sy-title.
  wa_layout-zebra      = 'X'.
  wa_layout-cwidth_opt = 'X'.
  wa_layout-sel_mode   = 'A'.
  wa_layout-info_fname = 'COLOR'.

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name = 'ZPSMONTH_OPTOUT'
    CHANGING
      ct_fieldcat      = gt_fieldcat.

 LOOP AT gt_fieldcat INTO wa_fieldcat.
    CASE wa_fieldcat-fieldname.
      WHEN 'NO_OF_EMPS' OR 'AUTO_OPTOUT'
            OR 'VOL_OPTOUT' OR 'VOL_OPTIN'
            OR 'NON_CONT_AVC' OR 'NON_CONT_NO_AVC'.
        wa_fieldcat-do_sum = 'X'.
        MODIFY gt_fieldcat FROM wa_fieldcat.
    ENDCASE.
  ENDLOOP.


  wa_sort-fieldname = 'DIVISION'.
  wa_sort-up = 'X'.
  wa_sort-subtot = 'X'.
  wa_sort-down = space.
  APPEND wa_sort TO it_sort.

  CALL METHOD alv_grid->set_table_for_first_display
      EXPORTING
        i_structure_name              = 'ZPSMONTH_OPTOUT'
        is_layout                     = wa_layout
*      it_toolbar_excluding          = t_ui_functions
      CHANGING
        it_outtab                     = it_output
        it_fieldcatalog               = gt_fieldcat
        it_sort                       = it_sort
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        OTHERS                        = 4.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

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 Jul 04, 2008 at 11:17 AM

    Hi,

    Please refer the code below:

     *  ALV data declarations
      data: it_sortcat     type LVC_T_SORT,
            it_sortcatdb   type LVC_T_SORT.
    
     perform build_sortcat.
    
    *&------------------------------------------------------------------*
    *&      Form  build_sortcat
    *&------------------------------------------------------------------*
    *       Build Sort catalog
    *-------------------------------------------------------------------*
    FORM build_sortcat .
      wa_sort-spos      = 1.
      wa_sort-fieldname = 'EBELN'.
      wa_sort-SUBTOT    = 'X'. "subtotals any totals column by this field
    *  gd_sortcat-tabname
      APPEND wa_sort TO it_sortcat.
    
      wa_sort-spos      = 2.
      wa_sort-fieldname = 'EBELP'.
    *  gd_sortcat-tabname
      APPEND wa_sort TO it_sortcat.
    ENDFORM.                    " build_sortcat
    
     
     CALL METHOD gd_tree->set_table_for_first_display
        EXPORTING
          is_layout       = gd_layout
        CHANGING
          it_fieldcatalog = gd_fieldcat
          it_sort         = it_sortcat
          it_outtab       = it_report.
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 04, 2008 at 06:17 PM

    Hi Sriram,

    I'm not sure if you have to use the wa_sort-up and wa_sort-down. Try to set it as a Command-Line and test it.

    Another idea is, sorry, is 'DIVISION' the right field?!

    Hope a give you an idea.

    Regards Dieter

    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.