Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALVsorting and subtotal.

Former Member
0 Likes
720

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
702

Hi,

Check the link for sorting wrt a field in ALV

and for SUBTOTAL check

You will get many example to solve your prob.

Regards,

anirban

6 REPLIES 6
Read only

Former Member
0 Likes
703

Hi,

Check the link for sorting wrt a field in ALV

and for SUBTOTAL check

You will get many example to solve your prob.

Regards,

anirban

Read only

naveen_inuganti2
Active Contributor
0 Likes
702

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.

Read only

Former Member
0 Likes
702

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.

Read only

Former Member
0 Likes
702

hi,

Refer to the link.

http://www.sapdev.co.uk/reporting/alv/alvgrid_sort.htm

Regards

Sumit Agarwal

Read only

Former Member
0 Likes
702

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

Read only

Former Member
0 Likes
702

Hi Amrutha,

Check out this link:

Regards,

Chandra Sekhar