Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV - Subtotals button greyed out

Former Member
0 Kudos

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.

3 REPLIES 3

Former Member
0 Kudos

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.

0 Kudos

Sorry Sriram Ponna, it still does not work

Even after i appended the sort table as suggested by you

Former Member
0 Kudos

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