hi,
at last statement will not work if you use the loop with index, unless I_max is last line of the internal table.
better you will try like this. do you know the i_max no means
write the code like this.
declare one index variable.
data : L_index type sy-index.
l_index = I_min.
LOOP AT it_out ASSIGNING <fs_out> FROM l_min TO l_max.
if l_index ne I_min.
l_index = index + 1.
endif.
if l_index eq I_max.
PERFORM total USING p_last.
endif.
ENDLOOP
Regards,
Kartik