Application Development and Automation 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: 
Read only

How do use 'do_sum' in fieldcat?

Former Member
0 Likes
9,262

Hello,

I am trying to use 'do_sum' in a fieldcat so I can sum up the column values of my internal table.
Here's what I have:

      i_fieldcat-fieldname = 'VALUE'.
     i_fieldcat-coltext = 'Value'.
     i_fieldcat-ref_table = 'i_tab'.
     i_fieldcat-ref_field = 'i_tab-value'.
     i_fieldcat-do_sum = 'X'.
     APPEND i_fieldcat TO t_fieldcat.

The problem is that the 'Sum' icon on the toolbar is disabled, so I can't do anything.

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
6,503

Hey, guys!

Replying to all of you: yes, I am using numeric values.
In fact, I am using 'TYPE i'. However, when I run my program the sum icon is still disabled.

Here's my toolbar:

Thanks a lot, everyone!

Hello,

I am trying to use 'do_sum' in a fieldcat so I can sum up the column values of my internal table.
Here's what I have:

      i_fieldcat-fieldname = 'VALUE'.
     i_fieldcat-coltext = 'Value'.
     i_fieldcat-ref_table = 'i_tab'.
     i_fieldcat-ref_field = 'i_tab-value'.
     i_fieldcat-do_sum = 'X'.
     APPEND i_fieldcat TO t_fieldcat.

The problem is that the 'Sum' icon on the toolbar is disabled, so I can't do anything.

Thanks in advance.

19 REPLIES 19
Read only

ronaldo_aparecido
Contributor
0 Likes
6,503

Hello Do_SUM when the code included in the total sum display column on the screen.

What are you talking about that icon that does not appear? can send a print?

Read only

arindam_m
Active Contributor
0 Likes
6,503

Hi,

Check the link below you should help you to activate the function.

http://help.sap.com/erp2005_ehp_04/helpdata/en/42/fb6abe46a21bc8e10000000a11466f/content.htm

Cheers,

Arindam

Read only

Former Member
0 Likes
6,503

hi Rafael,

I hope that you have numeric fields (qty or currency) in your final table. If you dont, then the summation button will not appear even after defining.

Please check your field and confirm.

Regards,

DN.

Read only

former_member15255
Active Participant
0 Likes
6,503

Hello Rafael,

None of the fields in the field catalog would be belonging to numeric,currency & quantity type.

Regards

Suresh Nair

Read only

Former Member
0 Likes
6,503

Hi,

Have you use SORT?

http://scn.sap.com/thread/1642567

Thanks,

Quynh.

Read only

Former Member
0 Likes
6,503

Hi Rafael,

If you use do_sum you can automatically get summation of the field in report.You just go through this link,

http://www.saphub.com/abap-tutorial/abap-alv-total-subtotal/

Read only

Former Member
0 Likes
6,503

following link i give example code pl check

http://scn.sap.com/thread/3167705

Read only

Former Member
0 Likes
6,503

Hi ,

    See below report,by this u'r problem will clear.

REPORT  ZDEMO_HEMANTH NO STANDARD PAGE HEADING.

TYPE-POOLS SLIS.

DATA ITF TYPE SLIS_T_FIELDCAT_ALV.

DATA WAF TYPE SLIS_FIELDCAT_ALV.

WAF-COL_POS = 1. "COLUMN POSITION

WAF-FIELDNAME = 'EBELN'. " FIELDNAME

WAF-SELTEXT_L = 'PO NUMBER'. " COLUMN HEADING

WAF-HOTSPOT = 'X'.

APPEND WAF TO ITF.

CLEAR WAF.

WAF-COL_POS = 2. "COLUMN POSITION

WAF-FIELDNAME = 'EBELP'. " FIELDNAME

WAF-SELTEXT_L = 'PO ITEM'. " COLUMN HEADING

WAF-NO_OUT = 'X'. " NO DISPLAY ON O/P SCREEN.

APPEND WAF TO ITF.

CLEAR WAF.

WAF-COL_POS = 3. "COLUMN POSITION

WAF-FIELDNAME = 'MATNR' ." FIELDNAME

WAF-SELTEXT_L = 'MATERIAL NO'. " COLUMN HEADING

WAF-EMPHASIZE = 'C301' ." COLOR C-COLOR, X 1-7, Y 0/1,Z 0/1.

APPEND WAF TO ITF.

CLEAR WAF.

WAF-COL_POS = 4. "COLUMN POSITION

WAF-FIELDNAME = 'NETPR' ." FIELDNAME

WAF-SELTEXT_L = 'NET PRICE'. " COLUMN HEADING

WAF-DO_SUM = 'X'. " TOTAL.

APPEND WAF TO ITF.

CLEAR WAF.

************************* LOGIC TO PREPARE SUB TOTAL ***************

DATA ITS TYPE SLIS_T_SORTINFO_ALV.

DATA WAS TYPE SLIS_SORTINFO_ALV.

WAS-FIELDNAME = 'EBELN'. "FIELD W.R.T PREPARE SORTING

WAS-SUBTOT = 'X'. " SUB TOTALS

APPEND WAS TO ITS.

TYPES : BEGIN OF STR,

EBELN TYPE EBELN,

EBELP TYPE EBELP,

MATNR TYPE MATNR,

NETPR TYPE NETPR,

END OF STR.

DATA IT TYPE TABLE OF STR.

SELECT EBELN EBELP MATNR NETPR FROM EKPO INTO TABLE IT UP TO 25 ROWS.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-CPROG

IT_FIELDCAT = ITF

IT_SORT = ITS

TABLES

T_OUTTAB = IT.

Regards,

Hemanth

Read only

Former Member
0 Likes
6,503

HI Rafael,

First of all, I hope you have the numeric field like I, P in your List. As given above, without any integer or numeric fields it will not be enabled.

If thats not the case, make this setting in your layout.

(If there is no layout, declare it in decalartions.

        gw_layo     type lvc_s_layo,    )

   gw_layo-NO_TOTLINE = ' '.

  gw_layo-NUMC_TOTAL = 'X'.  /* this will enable/disable summation for NUMC fields


create field catalog,

call ALV


CALL METHOD gv_gridref->set_table_for_first_display
     EXPORTING
       i_bypassing_buffer = 'X'
       is_variant         = gs_variant
       i_save             = 'X'
       is_layout          = gw_layo
     CHANGING
       it_outtab          = gt_out
       it_fieldcatalog    = gt_fcat.

or if you are using reuse_ALV_GRID_DISPLAY


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
       i_callback_program = sy-repid
       it_fieldcat        = gt_alv_fieldcat
       is_layout          = gw_layo
       i_default          = 'X'
       i_save             = 'X'
   TABLES
       t_outtab           = gt_out.

Let me know if it worked.

Thanks,

Susmitha

Read only

Former Member
0 Likes
6,504

Hey, guys!

Replying to all of you: yes, I am using numeric values.
In fact, I am using 'TYPE i'. However, when I run my program the sum icon is still disabled.

Here's my toolbar:

Thanks a lot, everyone!

Read only

0 Likes
6,503

Can  you forward your Feild catalog code and ALV FM, so that we can fix it

Also, From the output screen go to System --> status , double click on GUI Status and Expand Function Keys and see whether you have &UMC or &SUM icons?

With Regards,

Bala M

Read only

0 Likes
6,503

Hi, Rafael.

I think you can try this class

CL_ALV_GRID_TOOLBAR_MANAGER - ALV Grid Toolbar

Functionality

Reorganization of the toolbar of an ALV grid control.

The ALV grid control provides a whole range of functions.

If a certain application adds own functions to the toolbar, it can easily be the case that 20 to 30 functions appear in the toolbar.

The appearance of the toolbar is therefore not user-friendly and can be very confusing.

This class can be used to split the ALV toolbar into three levels:

  • Level 1 - only application-specific functions
  • Level 2 - application-specific functions plus ALV sort and totals functions
  • Level 3 - complete toolbar with all functions

If the ALV grid is editable, the editing functions are also available in each level.A new function key is added at the end of each toolbar, and you can use this key to expand or collapse the toolbar.This class should be used as follows:

  • In the event handler class of your ALV program you define an instance variable for the class CL_ALV_GRID_TOOLBAR_MANAGER.
  • In the constructor of the event handler class you create an instance of CL_ALV_GRID_TOOLBAR_MANAGER.
  • In the event handler method for the ALV Toolbar (such as ON_TOOLBAR) you create the toolbar in the normal manner. At the end of the method you then call the toolbar manager method .
  • Before you end the ALV event handler instance, save the current level of the toolbar using the method SAVE_STATE in your user settings.
Read only

0 Likes
6,503

Hi, Rafael.

There are another option you can take, which is using the method 'TOOLBAR_MODIFY' of the CL_GUI_ALV_GRID.

Read only

0 Likes
6,503

Hi Bala,

The fieldcatalog is the one I already posted. The ALV is receiving this fieldcatalog as usual.

     i_fieldcat-fieldname = 'VALUE'.
     i_fieldcat-ref_table = 'i_tab'.
     i_fieldcat-ref_field = 'i_tab-value'.
     i_fieldcat-do_sum = 'X'.
     APPEND i_fieldcat TO t_fieldcat.

I don't see in Function Keys neither &UMC nor &SUM icons.Though, this is not what I want.

My goal is to enable the SUM icon in the toolbar, not as a Function Key.

Thank you!

Read only

0 Likes
6,503

Comment this out.

  i_fieldcat-ref_field = 'i_tab-value'.

If still not working, add this line too.

  I_FIELDCAT-INTTYPE = 'P'.

Hope this solves it ..

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
6,503

Hello Rafael,

You should pass the ref_table & ref_fieldname in UPPERCASE only!

Anyway whenever you're facing problem with ALV try to run The Consistency Check (SAP Library - ALV Grid Control (BC-SRV-ALV))

BR,

Suhas

Read only

Former Member
0 Likes
6,503

  i_fieldcat-do_sum = 'X'. and apeend it to fieldcatalog internal table but remember ur field should be numeric type. it wont do sum if ur field is character or string type

Read only

0 Likes
6,503

Hi,

u can copy gui status 'STANDARD' from standard program SAPLSALV into ur report.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

     EXPORTING

       i_callback_program          = gd_repid

       i_callback_html_top_of_page = 'HTML_TOP_OF_PAGE'

       i_callback_user_command     = 'USER_COMMAND'

       it_fieldcat                 = fieldcatalog[]

       i_save                      = 'X'

       i_callback_pf_status_set    = 'STATUS_GUI'

       is_variant                  = g_variant

       is_layout                   = gd_layout

     TABLES

       t_outtab                    = it_final[]

     EXCEPTIONS

       program_error               = 1

       OTHERS                      = 2.

   IF sy-subrc = 0.

   ENDIF.

and write status_gui as perform routine in ur report as below

FORM status_gui  USING rt_extab TYPE slis_t_extab..

   SET PF-STATUS 'GUI1'.

ENDFORM.         

gui1 is status in which gui status standard is copied.

u can copy using t-code se41

Regards,

Gaurav Wani

Read only

Former Member
0 Likes
6,503

Hey, guys!

It is working now.

Thank you so much for all of your help!!