2013 Oct 02 2:42 AM
Hi experts,
attached is a picture of my report.
Can i put the value of the subtotal into a variable? Because i need to put the subtotal into another ALV by year.
Here is my code in getting the subtotal in alv.
x_fieldcat-fieldname = 'GRADUATES'.
x_fieldcat-seltext_l = 'Graduates'.
x_fieldcat-tabname = 'it_detailed'.
x_fieldcat-col_pos = 5.
x_fieldcat-outputlen = '17'.
x_fieldcat-do_sum = 'X'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
Like, gv_subtot = x_fieldcat-do_sum = 'X'.
is there any way that i can do that?
Thanks.
2013 Oct 03 7:44 AM
Hii calix,
you can't assign like
gv_subtot = x_fieldcat-do_sum = 'X'.
It will give u a dump.
To get subtotal u have to called the method get_subtotals of class cl_gui_alv_grid.
Do like below
Data: obj_grid type ref to cl_gui_alv_grid,
subtotal type ref to data.
field-symbol <subtotal> like <internal table> which u r displaying in alv
CALL METHOD obj_grid->get_subtotals
IMPORTING
ep_collect00 = subtotal. ---------this will hold the subtotal value.
assign subtotal->* to <subtotal>.
now proceed according to requirement
regards
Syed
Hi experts,
attached is a picture of my report.
Can i put the value of the subtotal into a variable? Because i need to put the subtotal into another ALV by year.
Here is my code in getting the subtotal in alv.
x_fieldcat-fieldname = 'GRADUATES'.
x_fieldcat-seltext_l = 'Graduates'.
x_fieldcat-tabname = 'it_detailed'.
x_fieldcat-col_pos = 5.
x_fieldcat-outputlen = '17'.
x_fieldcat-do_sum = 'X'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
Like, gv_subtot = x_fieldcat-do_sum = 'X'.
is there any way that i can do that?
Thanks.
2013 Oct 03 5:13 AM
2013 Oct 03 5:22 AM
Hi Jepoy,
Please check the below link, it might be helpful...
http://scn.sap.com/thread/519906
Regards,
Anubhab
2013 Oct 03 5:27 AM
Hi Jepoy,
You can use the method of the alv grid object given below:
CALL METHOD <ref. var. to CL_GUI_ALV_GRID > ->get_subtotals.
2013 Oct 03 5:45 AM
Hi,
I am using the OOPS and alv grid. The code i used is
CALL METHOD obj->fieldcatalog (Calling a method)
EXPORTING
fieldname = 'ROM_NO'
tablename = 'T_ROOM_BOOK'
length = '12'
text = 'Room Num'(004)
hotspot = 'X'
do_sum = ' '
emphasize = 'X'
IMPORTING
t_fieldcat = t_fieldcat.
Where t_fieldcat in an internal table for fieldcatalog.
Try this way,may it works. It works fine with mine.
Pass t_fieldcat to the grid function module calling ot through the grid object
set_table_for_first_display
it_fieldcatalog = t_fieldcat
Regards
2013 Oct 03 6:29 AM
Hi Amar,
Thanks
Satya
2013 Oct 03 7:13 AM
Hi
Fieldcatalog is not a standard method.I said i am using OOPS and gird view. This is what i coded.
Class C1 Implementation.
Method
fieldcatalog IMPORTING tablename TYPE lvc_tname
fieldname TYPE lvc_fname
length TYPE lvc_outlen
text TYPE lvc_txt
hotspot TYPE lvc_hotspt
emphasize TYPE lvc_emphsz
EXPORTING t_fieldcat TYPE lvc_t_fcat,
Endmethod.
Endclass
DATA obj_c1 TYPE REF TO c1.
START-OF-SELECTION.
CREATE OBJECT obj_c1.
CALL METHOD obj->fieldcatalog (Calling a method)
EXPORTING
fieldname = 'ROM_NO' "Field Name
tablename = 'T_ROOM_BOOK' " Internal Table
length = '12'
text = 'Room Num'
hotspot = 'X'
do_sum = ' '
emphasize = 'X'
IMPORTING
t_fieldcat = t_fieldcat.
I think the case with you is because of the way you are passing the variables to the fieldcatalog table fields. See that you provide the inverted commas properly. Sometime that can be an issue
Hope this time it works fine as it worked for mine.
Regards.
2013 Oct 03 7:22 AM
2013 Oct 03 6:00 AM
Hi Jepoy,
Folow this documentation .
http://help.sap.com/saphelp_erp2004/helpdata/en/9e/2c7b38180fee45e10000009b38f8cf/content.htm
Check this sample code.
http://www.sapwiki.cl/wiki/index.php?title=SAP_ABAP_ALV_cl_gui_alv_grid
2013 Oct 03 7:44 AM
Hii calix,
you can't assign like
gv_subtot = x_fieldcat-do_sum = 'X'.
It will give u a dump.
To get subtotal u have to called the method get_subtotals of class cl_gui_alv_grid.
Do like below
Data: obj_grid type ref to cl_gui_alv_grid,
subtotal type ref to data.
field-symbol <subtotal> like <internal table> which u r displaying in alv
CALL METHOD obj_grid->get_subtotals
IMPORTING
ep_collect00 = subtotal. ---------this will hold the subtotal value.
assign subtotal->* to <subtotal>.
now proceed according to requirement
regards
Syed