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: 

Unable to sum up column in ALV

rahul2000
Contributor
0 Kudos

Dear all,

i am using structure LVC_S_LAYO.

Here in my toolbar some icons like show next,summation are inactive.

Also i am using LVC_T_FCAT where i have set DO_SUM = 'X'.

When i see in debugging the value X is getting passed from my it_fieldcatalog table but still

the sum of the desired column is not displayed.what must be the problem?

Why are these icons inactive in the toolbar.?What should i do to Activate them?

4 REPLIES 4

Former Member
0 Kudos

for doing sum based on customer no( in your case).declare one internal table of type slis_t_sortinfo_alv and one work area and there is a parameter subtot pass X to that no and spos = '1'.

fieldname = 'KUNNR'.

tabname = 'LT_KNA1'.(internal table)

UP = 'X'.

subtot = 'X'.

your requirment is full filled.

i am sending the sample code for this but here i am doing based on the VBELN.


TYPE-POOLS: slis.
 
TYPES: BEGIN OF tw_vbap,
vbeln TYPE vbeln,
posnr TYPE posnr,
matnr TYPE matnr,
ernam TYPE ernam,
netwr TYPE netwr,
      END OF tw_vbap,
tt_vbap TYPE STANDARD TABLE OF tw_vbap.
 
 
 
DATA: lf_vbeln TYPE vbeln,
      lw_vbap TYPE tw_vbap,
      lt_vbap TYPE tt_vbap,
      lt_fieldcat TYPE slis_t_fieldcat_alv,
      lw_fieldcat LIKE LINE OF lt_fieldcat,
      lt_sort TYPE slis_t_sortinfo_alv,
      lw_sort LIKE LINE OF lt_sort.
*types: tt_layo type table of SLIS_LAYOUT_ALV.
DATA: lw_layo TYPE slis_layout_alv,
 
      lt_layo TYPE STANDARD TABLE OF  slis_layout_alv,
      lt_header TYPE slis_t_listheader,
      lw_header LIKE LINE OF lt_header.
 
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.
SELECT-OPTIONS: so_vbeln FOR lf_vbeln.
SELECTION-SCREEN END OF BLOCK b1.
 
START-OF-SELECTION.
  SELECT vbeln
          posnr
          matnr
          ernam
          netwr FROM vbap INTO TABLE lt_vbap WHERE vbeln IN so_vbeln.
  IF sy-subrc EQ 0.
 
    PERFORM layout.
    PERFORM build_fieldcat.
    PERFORM sort.
    PERFORM display.
 
  ENDIF.
*&---------------------------------------------------------------------*
*&      Form  build_fieldcat
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build_fieldcat .
  lw_fieldcat-col_pos = '1'.
  lw_fieldcat-fieldname = 'VBELN'.
  lw_fieldcat-tabname   = 'LT_VBAP'.
*lw_fieldcat-checkbox(1)  = 'X'.
  lw_fieldcat-emphasize(4) = 'C111'.
  lw_fieldcat-seltext_l  = 'SALES ORDER'.
  lw_fieldcat-seltext_m  = 'SAODER'.
  lw_fieldcat-seltext_s  = 'S.O'.
  APPEND lw_fieldcat TO lt_fieldcat.
 
  lw_fieldcat-col_pos = '2'.
  lw_fieldcat-fieldname = 'POSNR'.
  lw_fieldcat-tabname   = 'LT_VBAP'.
*lw_fieldcat-checkbox(1)  = 'X'.
  lw_fieldcat-emphasize(4) = 'C211'.
  lw_fieldcat-seltext_l  = 'ITEMNO'.
  lw_fieldcat-seltext_m  = 'ITEM'.
  lw_fieldcat-seltext_s  = 'I.N'.
  APPEND lw_fieldcat TO lt_fieldcat.
 
  lw_fieldcat-col_pos = '3'.
  lw_fieldcat-fieldname = 'MATNR'.
  lw_fieldcat-tabname   = 'LT_VBAP'.
*lw_fieldcat-checkbox(1)  = 'X'.
  lw_fieldcat-emphasize(4) = 'C311'.
  lw_fieldcat-seltext_l  = 'MATERIALNO'.
  lw_fieldcat-seltext_m  = 'MATERIAL'.
  lw_fieldcat-seltext_s  = 'MAT'.
  APPEND lw_fieldcat TO lt_fieldcat.
 
  lw_fieldcat-col_pos = '4'.
  lw_fieldcat-fieldname = 'ERNAM'.
  lw_fieldcat-tabname   = 'LT_VBAP'.
*lw_fieldcat-checkbox(1)  = 'X'.
  lw_fieldcat-emphasize(4) = 'C411'.
  lw_fieldcat-seltext_l  = 'PERSONCREATED'.
  lw_fieldcat-seltext_m  = 'PERCREATED'.
  lw_fieldcat-seltext_s  = 'PERCRE'.
  APPEND lw_fieldcat TO lt_fieldcat.
 
 
  lw_fieldcat-col_pos = '5'.
  lw_fieldcat-fieldname = 'NETWR'.
  lw_fieldcat-tabname   = 'LT_VBAP'.
*lw_fieldcat-checkbox(1)  = 'X'.
  lw_fieldcat-emphasize(4) = 'C311'.
  lw_fieldcat-seltext_l  = 'TOTALVALUE'.
  lw_fieldcat-seltext_m  = 'TOTAL'.
  lw_fieldcat-seltext_s  = 'TOT'.
  lw_fieldcat-do_sum = 'X'.
  APPEND lw_fieldcat TO lt_fieldcat.
 
 
 
ENDFORM.                    " build_fieldcat
*&---------------------------------------------------------------------*
*&      Form  layout
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM layout .
 
  lw_layo-colwidth_optimize = 'X'.
  lw_layo-zebra = 'X'.
  APPEND lw_layo TO  lt_layo.
ENDFORM.                    " layout
*&---------------------------------------------------------------------*
*&      Form  sort
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM sort .
  LW_SORT-spos = '1'.
  LW_SORT-fieldname = 'VBELN'.
  LW_SORT-tabname = 'LT_VBAP'.
  LW_SORT-UP = 'X'.
LW_SORT-subtot = 'X'.
 
APPEND LW_SORT TO LT_SORT.
 
 
*  LW_SORT-spos = '2'.
*  LW_SORT-fieldname = 'POSNR'.
*  LW_SORT-tabname = 'LT_VBAP'.
*  LW_SORT-UP = 'X'.
**  LW_SORT-subtot = 'X'.
*
*APPEND LW_SORT TO LT_SORT.
 
ENDFORM.                    " sort
*&---------------------------------------------------------------------*
*&      Form  display
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display .
 
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
     i_callback_program                = 'Z_SU_ALVOOPS1'
*   I_CALLBACK_PF_STATUS_SET          = ' '
*   I_CALLBACK_USER_COMMAND           = ' '
     i_callback_top_of_page            = 'TOP'
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
*     i_background_id                   = 'ENJOYSAP_LOGO'
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
*   IS_LAYOUT                         = LT_LAYO
     it_fieldcat                       = lt_fieldcat
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
     it_sort                           = lt_sort
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
*   I_SAVE                            = ' '
*   IS_VARIANT                        =
*   IT_EVENTS                         =
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   I_HTML_HEIGHT_TOP                 = 0
*   I_HTML_HEIGHT_END                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   IR_SALV_FULLSCREEN_ADAPTER        =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
    TABLES
      t_outtab                          = lt_vbap
* EXCEPTIONS
*   PROGRAM_ERROR                     = 1
*   OTHERS                            = 2
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
 
ENDFORM.                    " display
*&--------------------------------------------------------------------*
*&      Form  TOP
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
FORM top.
  lw_header-typ(1) = 'H'.
  lw_header-info  = 'SALESORDERITEM DATA'.
  APPEND lw_header TO lt_header.
  lw_header-typ(1) = 'S'.
  lw_header-info  = sy-datum.
  APPEND lw_header TO lt_header.
 
 
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary       = lt_header
     i_logo                   = 'SCREEN'
*   I_END_OF_LIST_GRID       =
*   I_ALV_FORM               =
            .

if helpful reward some points.

krishnannarayanan_nampoot
Active Participant
0 Kudos

Hi,

Please ensure that after the DO_SUM = 'X' u set NO_SUM = SPACE.

Second is if the Sum buttons are coming inactive and you are sure you haven't explicitly disabled them , then check for the data types as ALV is unable to perceive any summable columns in the Data u are passing.

I'll continue to see if any other parameters we are missing out.

Until then do chek these and update (<b>Do reward if this helps :)</b>

Regards,

0 Kudos

Dear On,

How do i check the datatypes.The column for which i want to add is of type I.

Former Member
0 Kudos

Hi,

Atleast one of the field in the fieldcatalog should be of type 'I' (integer). If not available, even if DO_SUM is set, it will be in disable mode.