04-25-2007 9:53 AM
Hi ,
My output display format is in ALV. I want to do Sum in the Grid without using any buttons . In that output I want to total the amount by month wise & Currency wise (USD,INR,EURO). I want the output like this..
-
Document no Date Netvalue currency
-
0090034253 22.02.2005 1,50.00 USD
0090034254 28.02.2005 1,50.00 USD
-
Total 300.00
-
0090034255 30.02.2005 1,50.00 INR
-
Total 150.00
-
0090034256 10.03.2005 1,50.00 USD
-
Total 150.00
-
0090034257 22.03.2005 1,50.00 EURO
0090034258 26.03.2005 1,50.00 EURO
-
Total 300.00
-
Grand Total 900.00
-
How can we do it..Please anyone help me to do like this without using any buttons.
Thanks..
04-25-2007 9:58 AM
Hi
Internal table to hold Sort/Subtotals criteria data
data: i_sort type slis_t_sortinfo_alv. " Table - sort/Subtotals
x_sort-fieldname = 'MONAT'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 1.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'WAERS'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 2.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
Build the i_sort table with the Fields Month and Currency as 1st and 2nd level of sorts
and pass this int table to ALV_GRID_DISPLAY fun module
it will do the sub totals and final totals.
use DO_SUM = 'X' for NETWR field for summing.
reward if useful
regards,
Anji
Message was edited by:
Anji Reddy Vangala
04-25-2007 9:57 AM
Sort the table first by month and then by Currency and check the total for amount field in field catalog on the amount.
Regards,
Amit
04-25-2007 9:58 AM
Hi
Internal table to hold Sort/Subtotals criteria data
data: i_sort type slis_t_sortinfo_alv. " Table - sort/Subtotals
x_sort-fieldname = 'MONAT'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 1.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'WAERS'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 2.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
Build the i_sort table with the Fields Month and Currency as 1st and 2nd level of sorts
and pass this int table to ALV_GRID_DISPLAY fun module
it will do the sub totals and final totals.
use DO_SUM = 'X' for NETWR field for summing.
reward if useful
regards,
Anji
Message was edited by:
Anji Reddy Vangala
04-25-2007 9:59 AM
Hi,
First put Do_sum = 'X' in the field catalog of 'Netvalue '
then pass
data: t_sort type slis_t_sortinfo,
w_sort type slis_sortinfo.
w_sort-fieldname = '<Document field name>'
w_sort_up = 'X'.
w_sort-subtot = 'X'.
append w_sort to t_sort and pass this to your FM
santhosh
04-25-2007 10:00 AM
in reuse_alv_grid_display
u have options to get sub totals .. call that events..
it will help u
04-25-2007 10:01 AM
04-25-2007 10:04 AM
If done with the OO ALV:
CALL METHOD grid->set_table_for_first_display
EXPORTING is_layout = gt_layout
is_variant = gs_variant
i_save = x_save
i_default = h_variant
CHANGING it_outtab = gt_outtab
it_fieldcatalog = gt_fieldcat
it_sort = gt_sort.
gt_sort can be used.
* SET_SORT_CRITERIA
CLEAR: wa_sort.
MOVE '1' TO wa_sort-spos.
MOVE 'EBELN' TO wa_sort-fieldname.
MOVE 'X' TO wa_sort-down.
APPEND wa_sort TO gt_sort.
CLEAR: wa_sort.
MOVE '2' TO wa_sort-spos.
MOVE 'IRGR' TO wa_sort-fieldname.
MOVE 'X' TO wa_sort-down.
MOVE 'X' TO wa_sort-subtot. <--- set subtotal flag
MOVE 'UL' TO wa_sort-group.
APPEND wa_sort TO gt_sort.
I know this is a bit short, but I hope it's clear. Should also be possible when using the function module.
04-25-2007 10:08 AM
Hi,
You need to fill in the 'IT_SORT' parameter of function module
'REUSE_ALV_LIST_DISPLAY'.
So you should be building IT_SORT table like following:
You need to have 'yearmon' field in your display table.
IT_SORT-SPOS = 1
IT_SORT-FIELDNAME = ''YEARMON'.
IT_SORT-UP = 'X'.
IT_SORT-SUBTOT = 'X'.
APPEND IT_SORT[].
IT_SORT-SPOS = 2
IT_SORT-FIELDNAME = ''CURRENCY'.
IT_SORT-UP = 'X'.
IT_SORT-SUBTOT = 'X'.
APPEND IT_SORT[].
and pass to the 'REUSE_ALV_LIST_DISPLAY'.
This will default subtotals without using buttons in toolbar.
Thanks and regards,
S. Chandra Mouli.
04-25-2007 10:31 AM
Hi,
I have coded like this..but i am getting Error "IT_SORT" is not a table without a header line& therefore no component called "SPOS" ,"Fieldname" "tabname"..
How can i solve it..Help me
<b>data: IT_sort type slis_t_sortinfo_alv.
PERFORM field_cat USING fieldcat.
IT_SORT-SPOS = 1.
IT_SORT-FIELDNAME = 'FKDAT'.
IT_SORT-tabname = 'T_OUT'.
IT_SORT-UP = 'X'.
IT_SORT-SUBTOT = 'X'.
APPEND IT_SORT[].
IT_SORT-SPOS = 2.
IT_SORT-tabname = 'T_OUT'.
IT_SORT-UP = 'X'.
IT_SORT-SUBTOT = 'X'.
APPEND IT_SORT[].
IT_SORT-SPOS = 2
IT_SORT-FIELDNAME = 'WAERK'.
CALL FUNCTION MODULE FOR ALV GRID DISPLAY.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
IS_LAYOUT = wa_layout
it_fieldcat = fieldcat
IT_SORT = IT_SORT
TABLES
t_outtab = t_out
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.
ENDIF.</b>
04-25-2007 10:39 AM
change
data: IT_sort type slis_t_sortinfo_alv.
to
data: IT_sort type slis_t_sortinfo_alv with header line.
santhosh
04-25-2007 10:39 AM
change ur declaration like this
data :it_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv.
and use wa_sort , and append that to it_sort
04-25-2007 10:41 AM
Declare like this.
data: IT_sort type slis_t_sortinfo_alv,
it_sort1 type SLIS_SORTINFO_ALV.
IT_SORT1-SPOS = 1.
IT_SORT1-FIELDNAME = 'FKDAT'.
IT_SORT1-tabname = 'T_OUT'.
IT_SORT1-UP = 'X'.
IT_SORT1-SUBTOT = 'X'.
APPEND IT_SORT1 to it_sort.
IT_SORT1-SPOS = 2.
IT_SORT1-tabname = 'T_OUT'.
IT_SORT1-UP = 'X'.
IT_SORT1-SUBTOT = 'X'.
APPEND IT_SORT1 to it_sort.
04-25-2007 11:12 AM
Hi Sadiq,
It is split montly wise and Currency wise...But i didnt get the "Total"..Plz correct my coding below..Also how to Give the text "Total" & "Subtotal" in the Grid..
<b>IT_SORT1-SPOS = 1.
IT_SORT1-FIELDNAME = 'MONTH'.
IT_SORT1-tabname = 'T_OUT'.
IT_SORT1-UP = 'X'.
IT_SORT1-SUBTOT = 'X'.
APPEND IT_SORT1 to it_sort.
IT_SORT1-SPOS = 2.
*IT_SORT-FIELDNAME = 'WAERK'.
IT_SORT1-tabname = 'T_OUT'.
IT_SORT1-UP = 'X'.
IT_SORT1-SUBTOT = 'X'.
APPEND IT_SORT1 to it_sort.
CALL FUNCTION MODULE FOR ALV GRID DISPLAY.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
IS_LAYOUT = wa_layout
it_fieldcat = fieldcat
IT_SORT = IT_SORT
TABLES
t_outtab = t_out
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.
ENDIF.</b>
04-25-2007 11:17 AM
hi
For Total add this:
IT_FIELDCAT-DO_SUM = 'X'.
for subtotal and total's text:
DATA : l_layout TYPE slis_layout_alv .
l_layout-subtotals_text = 'text'.
l_layout-totals_text = 'text'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = l_layout
**reward if helpful
regards,
madhu
04-25-2007 11:25 AM
Pass 'X' to do_sum parameter in fieldcatalog for field you want to do sum like amount field.
l_fieldcat-fieldname = 'AMOUNT'.
l_fieldcat-tabname = 'IT_OUT' .
l_fieldcat-seltext_l = 'Amt'.
l_fieldcat-do_sum = 'X'.
04-25-2007 11:48 AM
Total is working fine..how to display text "Total" & "Subtotal" in the output Grid display..I used the Following code ...But i didnt get it
<b>DATA : l_layout TYPE slis_layout_alv .
l_layout-subtotals_text = 'TOTAL'.
l_layout-totals_text = ''GRAND TOTAL'.
Then i passed it to
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
IS_LAYOUT = l_layout
it_fieldcat = fieldcat
IT_SORT = IT_SORT
TABLES
t_outtab = t_out
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.
ENDIF</b>.
04-25-2007 11:53 AM
l_layout-subtotals_text = 'TOTAL'.
l_layout-totals_text = ''GRAND TOTAL'.
append l_layout.
then pass it to the function.
reward if helpful
regards,
madhu
05-05-2009 9:45 AM