2013 May 13 7:17 PM
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.
2013 May 14 3:02 PM
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!
2013 May 13 9:16 PM
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?
2013 May 13 10:54 PM
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
2013 May 14 2:35 AM
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.
2013 May 14 5:39 AM
Hello Rafael,
None of the fields in the field catalog would be belonging to numeric,currency & quantity type.
Regards
Suresh Nair
2013 May 14 5:52 AM
2013 May 14 5:59 AM
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/
2013 May 14 6:15 AM
2013 May 14 6:24 AM
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
2013 May 14 6:28 AM
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
2013 May 14 3:02 PM
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!
2013 May 14 3:33 PM
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
2013 May 14 3:45 PM
Hi, Rafael.
I think you can try this class
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:
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:
2013 May 14 3:49 PM
Hi, Rafael.
There are another option you can take, which is using the method 'TOOLBAR_MODIFY' of the CL_GUI_ALV_GRID.
2013 May 14 9:53 PM
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!
2013 May 15 6:59 AM
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 ..
2013 May 15 7:20 AM
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
2013 May 15 6:18 AM
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
2013 May 15 6:24 AM
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
2013 May 16 2:28 PM
Hey, guys!
It is working now.
Thank you so much for all of your help!!