04-19-2010 12:08 PM
Hi,
I am facing a problem regarding total and sub-total in the REUSE_ALV_GRID_DISPLAY Function module.
Actually its not a problem, its a requirement.
In my report, i have several currencies like USD,SGD and JPY.
My BA told me to do subtotal of all the currencies, its not a big issue.
But she also wants Final Total will not be displayed, as it contains total from different currencies.
It means she only wants subtotal of different currencies as final total.
Like if report has 3 different currencies, then report will have 3 sub-totals as final totals.
Please help me.
Regards
Deepak.
04-19-2010 4:02 PM
you must check you're alv structure. the field with the currency must also be connected to the field with the amount otherwise it is not clear that the amount belongs to a specific currency also
look in se11 at you're structure the TAB currency/quantity fieldsand check if you see the the currency field at the reference structure and field name
the reference structure is equal to the alv structure
here an example of mine with articles where I could ofcourse also not totalize different articles with different units
structure ZALV_AFREKENINGTUSSENORDER_2 under tab currency/quantity fields
MENGE MENGE_D Hoeveelheid QUAN ZALV_AFREKENINGTUSSENORDER_2 MEINS
MEINS MEINS Basishoeveelheidseenheid UNIT
in this case it is impossible to get a grand total, all totals are summed according to their currency in you're case.
kind regards
arthur
Edited by: A. de Smidt on Apr 19, 2010 5:19 PM
Edited by: A. de Smidt on Apr 19, 2010 5:20 PM
04-19-2010 12:21 PM
Please search you will get lots of solutions on this.
Go this way:
REFRESH gt_sort.
CLEAR wa_sort.
wa_sort-fieldname = 'fieldname'.<-----that you want to sort and subtotal
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
wa_sort-tabname = 'IT_OUTPUT'.
APPEND wa_sort TO gt_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_top_of_page = 'TOP_OF_PAGE'
is_layout = gt_layout
it_fieldcat = it_fcat
it_sort = gt_sort[]
TABLES
t_outtab = it_output.
At last in field catalog pass
wa_fcat-do_sum = 'X'
.
04-19-2010 1:52 PM
Thanks Manas for your reply..
But my major concern is that i only want sub-total, not the grand total.
Like if in final output...i have three different currencies, then i only wants 3 blocks of output i.e. for different currencies.
No grand total requires in the final output.
Grand output is not required because it contains summation of all three which is inappropriate.
Please help me.
Regards
Deepak.
04-19-2010 2:27 PM
[Displaying Sub-total in ALV|http://www.s-a-p-t-e-c-h-n-i-c-a-l.com/Tutorials/ALV/Subtotals/text.htm]
04-19-2010 3:54 PM
Hi,
how can you have subtotals w/o having totals? This does not make sense.
But anyways, when you have three different currencies you will of cours get three totals. This is handeled by ALV because of your assignment of the value field to the currency field. If you get only 1 total line, then something is wrong.
Kind regards,
Thomas
04-19-2010 4:02 PM
you must check you're alv structure. the field with the currency must also be connected to the field with the amount otherwise it is not clear that the amount belongs to a specific currency also
look in se11 at you're structure the TAB currency/quantity fieldsand check if you see the the currency field at the reference structure and field name
the reference structure is equal to the alv structure
here an example of mine with articles where I could ofcourse also not totalize different articles with different units
structure ZALV_AFREKENINGTUSSENORDER_2 under tab currency/quantity fields
MENGE MENGE_D Hoeveelheid QUAN ZALV_AFREKENINGTUSSENORDER_2 MEINS
MEINS MEINS Basishoeveelheidseenheid UNIT
in this case it is impossible to get a grand total, all totals are summed according to their currency in you're case.
kind regards
arthur
Edited by: A. de Smidt on Apr 19, 2010 5:19 PM
Edited by: A. de Smidt on Apr 19, 2010 5:20 PM
04-19-2010 4:57 PM
Hi,
Test the following code,it could solve your problem.
TABLES : vbak.
TYPE-POOLS: slis. " ALV Global types
SELECT-OPTIONS :
s_vkorg FOR vbak-vkorg, " Sales organization
s_kunnr FOR vbak-kunnr, " Sold-to party
s_vbeln FOR vbak-vbeln. " Sales document
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
DATA:
BEGIN OF gt_vbak OCCURS 0,
vkorg LIKE vbak-vkorg, " Sales organization
kunnr LIKE vbak-kunnr, " Sold-to party
vbeln LIKE vbak-vbeln, " Sales document
netwr LIKE vbak-netwr, " Net Value of the Sales Order
waerk LIKE vbak-waerk, " Document currency
END OF gt_vbak.
----
INITIALIZATION.
v_1 = 'Maximum of records to read'.
----
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_display_data.
----
Form f_read_data
----
FORM f_read_data.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
FROM vbak
UP TO p_max ROWS
WHERE kunnr IN s_kunnr
AND vbeln IN s_vbeln
AND vkorg IN s_vkorg.
ENDFORM. " F_READ_DATA
----
Form f_display_data
----
FORM f_display_data.
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = 'VBAK'.
ls_fieldcat-do_sum = &2.
ls_fieldcat-cfieldname = &3.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_sort.
add 1 to ls_sort-spos.
ls_sort-fieldname = &1.
ls_sort-up = 'X'.
ls_sort-subtot = &2.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_layout TYPE slis_layout_alv.
m_fieldcat 'VKORG' '' ''.
m_fieldcat 'KUNNR' '' ''.
m_fieldcat 'VBELN' '' ''.
m_fieldcat 'NETWR' 'X' 'WAERK'.
m_fieldcat 'WAERK' '' ''.
m_sort 'VKORG' 'X'. " Sort by vkorg and subtotal
m_sort 'KUNNR' 'X'. " Sort by kunnr and subtotal
m_sort 'VBELN' ''. " Sort by vbeln
ls_layout-cell_merge = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
it_sort = lt_sort
TABLES
t_outtab = gt_vbak.
ENDFORM. " F_DISPLAY_DATA
Thanks.
Ramya.
04-26-2010 8:19 AM
and deepaks, any luck with one of the suggestions ??
kind regards
arthur
04-26-2010 9:15 AM
Hi all...
Thanks to all of you for your suggestions and code...but my problem was not solved properly.
I have no option for displaying only subtotal, without the grand-total.
I am giving you points.
Thanks again.
Deepak Sharma.
04-26-2010 10:14 AM
it is no programming sollution but a structure change, just follow my change of structure precisely and it will be impossible to get a grand total.
if you don't understand how to change you're structure please say what you don't understand.
kind regards
arthur
Edited by: A. de Smidt on Apr 26, 2010 11:15 AM
07-13-2011 11:07 AM
Hi Deepak,
You can hide the grand total display in the ALV grid display by using the option <no_totalline> in is_layout parameter in the FM, pass ' X' for this field and only sub totals will be displayed and the grand total that is coming as the last row will not be visible.
Regards,
Anoop.
07-13-2011 1:42 PM
please follow the steps below ..
Assuming your internal table has the 2 fields
total type DMBTR and
WAERK type WAERK
..
In your field catalog for totals should contain these fields ....
wa_field-fieldname = 'TOTALS'.
wa_field-cfieldname = 'WAERK'.
wa_field-do_sum = 'X'.
In your layout add line
wa_layout-no_totalline = 'X'.
Hope this solves your problem..
07-13-2011 1:43 PM
please follow the steps below ..
Assuming your internal table has the 2 fields
total type DMBTR and
WAERK type WAERK
..
In your field catalog for totals should contain these fields ....
wa_field-fieldname = 'TOTALS'.
wa_field-cfieldname = 'WAERK'.
wa_field-do_sum = 'X'.
In your layout add line
wa_layout-no_totalline = 'X'.
Hope this solves your problem..
04-26-2010 12:20 PM
REFRESH gt_sort.
CLEAR wa_sort.
wa_sort-fieldname = 'fieldname'.<-----that you want to sort and subtotal
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
wa_sort-tabname = 'IT_OUTPUT'.
APPEND wa_sort TO gt_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_top_of_page = 'TOP_OF_PAGE'
is_layout = gt_layout
it_fieldcat = it_fcat
it_sort = gt_sort[]
TABLES
t_outtab = it_output.
07-13-2011 2:18 PM
Hi,
You have to hide Total Line in the layout structure
Ex: IS_LAYOUT-NO_TOTALLINE = 'X'.
Regards,
Moqeeth.