‎2006 Sep 14 9:07 AM
HI experts,
this is my client requirement .after display ALV report we press back button in that screen i want total of records and sub totals for selected tables .
plz any one help me
Thanks,
venkat
‎2006 Sep 14 9:22 AM
Hi,
To get grand total pass X to 'do_sum' in field catalog for numeric or amount fields.
To get subtotal fill SORT table for ALV
Ex:
gs_sort TYPE slis_sortinfo_alv,
gt_sort LIKE gs_sort OCCURS 0.
Suppose if u want subtotal if there is change in company code(BUKRS) or cost centre(KOSTL, below is the sample code.
*Sub Total
IF ls_line-ref_fieldname = 'BUKRS'.
CLEAR gs_sort.
gs_sort-fieldname = 'BUKRS'.
gs_sort-spos = 1.
gs_sort-up = 'X'.
gs_sort-subtot = 'X'.
APPEND gs_sort TO gt_sort.
ELSEIF ls_line-ref_fieldname = 'KOSTL'.
CLEAR gs_sort.
gs_sort-fieldname = 'KOSTL'.
gs_sort-spos = 2.
gs_sort-up = 'X'.
gs_sort-subtot = 'X'.
APPEND gs_sort TO gt_sort.
ENDIF.
Regards
Divakar
‎2006 Sep 14 9:25 AM
Hello Venkat,
Use this code.
DATA: IT_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA: IT_VARIANT LIKE DISVARIANT,
G_S_SORT LIKE LINE OF IT_SORT.
REFRESH IT_SORT.
CLEAR: G_S_SORT,G_S_SORT.
G_S_SORT-SPOS = 1.
G_S_SORT-FIELDNAME = 'EBELN'.
G_S_SORT-UP = 'X'.
G_S_SORT-DOWN = ' '.
<b> G_S_SORT-SUBTOT = 'X'.</b> G_S_SORT-EXPA = ' '.
APPEND G_S_SORT TO IT_SORT.
For getting the grandtotal do in fillinng field cat.
Net order value
CLEAR L_FIELDCAT.
L_FIELDCAT-TABNAME = 'G_T_OUTTAB'.
L_FIELDCAT-FIELDNAME = 'NETWR'.
L_FIELDCAT-SELTEXT_M = TEXT-019.
L_FIELDCAT-COL_POS = 15.
L_FIELDCAT-CFIELDNAME = 'WAERS1'.
L_FIELDCAT-DO_SUM = 'X'.
APPEND L_FIELDCAT TO IT_FIELDCAT.
CLEAR L_FIELDCAT.
If useful reward.
Vasanth
‎2006 Sep 14 2:09 PM
Venkat,
If you want the totals/subtotals after the ALV, then all you need to do is to put source code producing this output just after the call to the ALV.
John
‎2006 Sep 14 2:30 PM
Hi Venkat,
Simply use write statements in end-of-selection.
Generally when you are showing ALV report, when you press back button it will show the report(if any thing there).
Try this....
-Anu