07-03-2007 5:40 AM
07-03-2007 6:19 AM
Hi,
take help of the below code.
FORM build_fieldcat CHANGING p_it_fieldcat LIKE it_fieldcat.
DATA : wa_fieldcat TYPE slis_fieldcat_alv,
l_col_pos TYPE i.
l_col_pos = l_col_pos + 1.
wa_fieldcat-col_pos = l_col_pos.
wa_fieldcat-fieldname = 'NETWR'.
wa_fieldcat-ref_fieldname = 'NETWR'.
wa_fieldcat-ref_tabname = 'VBRP'.
wa_fieldcat-cfieldname = 'WAERK'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-seltext_l = 'Net Sales Value'.
APPEND wa_fieldcat TO p_it_fieldcat.
CLEAR wa_fieldcat.
l_col_pos = l_col_pos + 1.
wa_fieldcat-col_pos = l_col_pos.
wa_fieldcat-fieldname = 'WAERK'.
wa_fieldcat-ref_fieldname = 'WAERK'.
wa_fieldcat-ref_tabname = 'VBRK'.
APPEND wa_fieldcat TO p_it_fieldcat.
CLEAR wa_fieldcat.
NEW Andreas Retzlaff
l_col_pos = l_col_pos + 1.
wa_fieldcat-col_pos = l_col_pos.
wa_fieldcat-fieldname = 'WAVWR'.
wa_fieldcat-ref_fieldname = 'WAVWR'.
wa_fieldcat-ref_tabname = 'VBRP'.
wa_fieldcat-cfieldname = 'WAERK'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO p_it_fieldcat.
CLEAR wa_fieldcat.
l_col_pos = l_col_pos + 1.
wa_fieldcat-col_pos = l_col_pos.
wa_fieldcat-fieldname = 'GMV'.
wa_fieldcat-ref_fieldname = 'WAVWR'.
wa_fieldcat-ref_tabname = 'VBRP'.
wa_fieldcat-cfieldname = 'WAERK'.
wa_fieldcat-seltext_s = 'GMV'.
wa_fieldcat-seltext_m = 'GMV'.
wa_fieldcat-seltext_l = 'GMV'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO p_it_fieldcat.
CLEAR wa_fieldcat.
endform.
*////for subtotal
FORM build_sortinfo CHANGING p_it_sortinfo LIKE it_sortinfo.
DATA : wa_sortinfo TYPE slis_sortinfo_alv.
wa_sortinfo-fieldname = 'BUKRS'.
wa_sortinfo-tabname = 'VBRK'.
wa_sortinfo-up = 'X'.
wa_sortinfo-subtot = 'X'.
APPEND wa_sortinfo TO p_it_sortinfo.
wa_sortinfo-fieldname = 'VBELN'.
wa_sortinfo-tabname = 'VBAK'.
wa_sortinfo-up = 'X'.
wa_sortinfo-subtot = 'X'.
APPEND wa_sortinfo TO p_it_sortinfo.
ENDFORM. " build_sortinfo
regards,
sudha
07-03-2007 5:42 AM
Hi
see this links
subtotals in ALV
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
<b>Reward points for useful Answers</b>
Regards
Anji
07-03-2007 5:43 AM
07-03-2007 5:43 AM
Hi,
By using Control break statements,
At new
At end of....
and Sum statement.
Regards,
07-03-2007 5:47 AM
Hi,
In fieldcatalog for that field, do_sum = 'X'.
Message was edited by:
Jayanthi Jayaraman
07-03-2007 5:47 AM
Hi,
please check out the following link it might help you
http://help.sap.com/saphelp_sm32/helpdata/en/16/7b9938ac52d205e10000009b38f8cf/frameset.htm
************please reward points if the information is helpful to you******************
07-03-2007 5:48 AM
Hi,
In the fieldcatalog for the field which you need the total, set the flag for do_sum to 'X'.
fieldcat-do_sum = 'X' and pass the fieldcat to ALV display Function module.
Regards,
Sharmila
07-03-2007 6:10 AM
hi,
To do totals we have one option in field catalog i.e., do_sum option .
For subtotals we hav one option sub totals only.
07-03-2007 6:19 AM
Hi,
take help of the below code.
FORM build_fieldcat CHANGING p_it_fieldcat LIKE it_fieldcat.
DATA : wa_fieldcat TYPE slis_fieldcat_alv,
l_col_pos TYPE i.
l_col_pos = l_col_pos + 1.
wa_fieldcat-col_pos = l_col_pos.
wa_fieldcat-fieldname = 'NETWR'.
wa_fieldcat-ref_fieldname = 'NETWR'.
wa_fieldcat-ref_tabname = 'VBRP'.
wa_fieldcat-cfieldname = 'WAERK'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-seltext_l = 'Net Sales Value'.
APPEND wa_fieldcat TO p_it_fieldcat.
CLEAR wa_fieldcat.
l_col_pos = l_col_pos + 1.
wa_fieldcat-col_pos = l_col_pos.
wa_fieldcat-fieldname = 'WAERK'.
wa_fieldcat-ref_fieldname = 'WAERK'.
wa_fieldcat-ref_tabname = 'VBRK'.
APPEND wa_fieldcat TO p_it_fieldcat.
CLEAR wa_fieldcat.
NEW Andreas Retzlaff
l_col_pos = l_col_pos + 1.
wa_fieldcat-col_pos = l_col_pos.
wa_fieldcat-fieldname = 'WAVWR'.
wa_fieldcat-ref_fieldname = 'WAVWR'.
wa_fieldcat-ref_tabname = 'VBRP'.
wa_fieldcat-cfieldname = 'WAERK'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO p_it_fieldcat.
CLEAR wa_fieldcat.
l_col_pos = l_col_pos + 1.
wa_fieldcat-col_pos = l_col_pos.
wa_fieldcat-fieldname = 'GMV'.
wa_fieldcat-ref_fieldname = 'WAVWR'.
wa_fieldcat-ref_tabname = 'VBRP'.
wa_fieldcat-cfieldname = 'WAERK'.
wa_fieldcat-seltext_s = 'GMV'.
wa_fieldcat-seltext_m = 'GMV'.
wa_fieldcat-seltext_l = 'GMV'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO p_it_fieldcat.
CLEAR wa_fieldcat.
endform.
*////for subtotal
FORM build_sortinfo CHANGING p_it_sortinfo LIKE it_sortinfo.
DATA : wa_sortinfo TYPE slis_sortinfo_alv.
wa_sortinfo-fieldname = 'BUKRS'.
wa_sortinfo-tabname = 'VBRK'.
wa_sortinfo-up = 'X'.
wa_sortinfo-subtot = 'X'.
APPEND wa_sortinfo TO p_it_sortinfo.
wa_sortinfo-fieldname = 'VBELN'.
wa_sortinfo-tabname = 'VBAK'.
wa_sortinfo-up = 'X'.
wa_sortinfo-subtot = 'X'.
APPEND wa_sortinfo TO p_it_sortinfo.
ENDFORM. " build_sortinfo
regards,
sudha