Application Development 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: 

subtotal calculation in ALV

sushant_singh
Participant
0 Kudos

hi all,

i need to calculate montly subtotal value of a field in ALV ( OO),

how can i do that.

plz send the code also.

thanks in advance.

regards

sushant singh

2 REPLIES 2

Former Member
0 Kudos

Hi Sushant,

try :

clear sort.

sort-fieldname = 'MATNR'.

sort-tabname = 'INTERNAL TABLE NAME'

sort-up = 'X'.

SORT-SUBTOT = 'X'.

append sort to t_sort.

clear sort.

Pass This t_sort ITAB in FM REUSE_ALV_GRID_DISPLAY as

it_sort = t_sort[]

Reward points if this helps.

Manish

Former Member
0 Kudos

Hi,

1) Create a sort internal table for you to do sub totaling based on the field change..In this example..I have created a sort internal table and it will sum for every change in the field VBELN.

data: gs_sort type lvc_s_sort.

data: gt_sort type lvc_t_sort.

gs_sort-fieldname = 'VBELN'.

gs_sort-UP = 'X'.

gs_sort-SUBTOT = 'X'.

append gs_sort to gt_sort.

Pass the internal table GT_SORT to the parameter

it_sort = gt_sort

of the method set_table_for_first_display..

2) For the field you have to do sum in the field catalog have the field DO_SUM = 'X'..

Thanks,

Naren