‎2008 Aug 05 7:19 AM
Hi all,
In ALV.. i have to sort the grid according to date field, this date field is of format mmddyyyy.
Here i need to sort it month wise.
Also in this case, after sorting i need to do the sub total of other numeric field monthwise...ie at the end of all
JAN month entries. i want sub total of the numeric field.
Please help me with the same.
Regards,
Amruta.
‎2008 Aug 05 7:22 AM
‎2008 Aug 05 7:22 AM
‎2008 Aug 05 7:25 AM
Hi....
In data declaration...
>data: w_sortinfo TYPE slis_sortinfo_alv,
> t_sortinfo TYPE slis_t_sortinfo_alv.
In field cat appending....
> w_fieldcat-seltext_m = 'NET VALUE'.
> W_FIELDCAT-DO_SUM = 'X'.
> APPEND w_fieldcat TO t_fieldcat.
> CLEAR w_fieldcat.
and after appending the field cat.....now sort table appending...
> W_SORTINFO-FIELDNAME = <field for sorting>.
> w_sortinfo-subtot = 'X'.
> APPEND w_sortinfo TO t_sortinfo.
> CLEAR w_sortinfo.
in grid FM...
> it_sort = t_sortinfo
Try this,
Thanks,
Naveen Inuganti.
‎2008 Aug 05 7:26 AM
1. have an extra field to store the month when you are defining the internal table,
2. After internal table population populate the month value from the date.
3. populate the fieldcatalog for Month also , but make it invisible
using no_out = 'X'.
4. For field which you want totals/subtota value use DO_SUM = 'X'. in fieldcatalog.
5. Populate the sort table based on the month number which you populated in step2.
sort-fieldname = 'MONTH'.
sort-up = 'X'.
sort-subtot = 'X'.
append sort to it_sort.6. pass the sort information to ALV function.
‎2008 Aug 05 7:26 AM
‎2008 Aug 05 7:26 AM
Follow tis code:
DATA: gt_sort TYPE slis_t_sortinfo_alv.
CLEAR gs_sort.
gs_sort-fieldname = 'LDDAT'.
gs_sort-spos = 1.
gs_sort-up = 'X'.
gs_sort-subtot = 'X'.
APPEND gs_sort TO gt_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_user_command = 'PROCESS_USER_COMMANDS'
is_layout = w_layout
it_fieldcat = i_fieldcat[]
it_sort = gt_sort[]
i_default = 'X'
i_save = 'A'
it_events = v_events
is_print = w_print
TABLES
t_outtab = i_final1
‎2008 Aug 05 7:29 AM