ALV

Question: How can i put subtotals at the bottom rows so that it will look like a summary of each value i subtotalled...
as an example the subtotal salaries per department

subtotal for FINANCE xxx.xx
subtotal for SUPPLY xxx.xx
subtotal for PROJECT xxx.xx

Answer:
REUSE_ALV_HIERSEQ_LIST_DISPLAY
_________________
Sudhi Karkada

Answer:
Go thruough the examples listed in the below link
http://www.sap-basis-abap.com/sapabap01.htm

Answer:
hi,
DATA: gt_sortcatalog type lvc_t_sort with header line.
We have to mention the fields based on which the subtotaling has to be done. Moreover the field catalogue should be filled when u require subtotaling so without filling the catalog we cannot achieve. For all the fields that you want to subtotal you have to set the field do_sum to ‘X’ .
First fill the field catalogue .
data: gt_fieldcat type LVC_T_FCAT .
data: ls_fcat type LVC_T_FCAT with header line.

CLEAR ls_fcat.
ls_fcat-tabname = 'gi_sflight'.
ls_fcat-fieldname = 'CARRID'.
ls_fcat-seltext = 'CARRID'.
ls_fcat-coltext = 'CARRID'.
APPEND ls_fcat TO gt_fieldcat.


CLEAR ls_fcat.
ls_fcat-tabname = 'gi_sflight'.
ls_fcat-fieldname = 'CONNID'.
ls_fcat-seltext = 'CONNID'.
ls_fcat-coltext = 'CONNID'.
APPEND ls_fcat TO gt_fieldcat.

CLEAR ls_fcat.
ls_fcat-tabname = 'gi_sflight'.
ls_fcat-fieldname = 'CONNID'.
ls_fcat-seltext = 'CONNID'.
ls_fcat-coltext = 'CONNID'.
APPEND ls_fcat TO gt_fieldcat.

CLEAR ls_fcat.
ls_fcat-tabname = 'gi_sflight'.
ls_fcat-fieldname = 'PRICE'.
ls_fcat-seltext = 'PRICE'.
ls_fcat-coltext = 'PRICE'.
ls_fcat-do_sum = 'X'.
APPEND ls_fcat TO gt_fieldcat.

CLEAR ls_fcat.
ls_fcat-tabname = 'gi_sflight'.
ls_fcat-fieldname = 'PAYMENTSUM'.
ls_fcat-seltext = 'PAYMENTSUM'.
ls_fcat-coltext = 'PAYMENTSUM'.
ls_fcat-do_sum = 'X'.
APPEND ls_fcat TO gt_fieldcat.

CLEAR ls_fcat.
ls_fcat-tabname = 'gi_sflight'.
ls_fcat-fieldname = 'SEATSOCC'.
ls_fcat-seltext = 'SEATSOCC'.
ls_fcat-coltext = 'SEATSOCC'.
ls_fcat-do_sum = 'X'.
APPEND ls_fcat TO gt_fieldcat.
So now instead of filling all the fields we decided only to fill only five fields and for three fields PRICE, PAYMENTSUM , SEATSOCC we opted to find subtotals . But at what level we are finding the sub-total is governed by the sortcatalog . for eg if we want it at the carrid level we have to fill the sortcat as follows.




REFRESH gt_sortcatalog.
CLEAR gt_sortcatalog.
gt_sortcatalog-fieldname = 'CARRID'.
Gt_sortcatalog-up = ‘X’.
gt_sortcatalog-subtot = ‘X’.
gt_sortcatalog-group = 'UL'.
APPEND gt_sortcatalog.
CLEAR gt_sortcatalog.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING

is_layout = gv_layout
CHANGING
it_fieldcatalog = gt_fieldcat
it_outtab = gi_sflight
it_sort = gt_sortcatalog[].
i think this will answer ur question.
Copyright ?2007 - 2008 www.jt77.com