‎2007 May 11 12:32 PM
i have three fields in my Disp_body, internal table to get data from database.fields are Sno, department and amount. i want suntotal according to departments. Sno is like an index. Now as i do subtotal i need to do sorting on de[partment so Sno get changed and i dont get the proper sequence in the output. do v have any provision in ALV for this.. or sm solution to get the proper output.
‎2007 May 11 12:36 PM
Hello,,
U remove that sno from ur internal table(as u told thats like an index)...
and sort he internal table by dept...
and then..
loop at it_xyz.
write: sy-tabix.
at end of dept.
sum.
endat.
write : dept,,the amount field.
endloop.
Cheers,
Ravi
‎2007 May 11 12:36 PM
Hello,,
U remove that sno from ur internal table(as u told thats like an index)...
and sort he internal table by dept...
and then..
loop at it_xyz.
write: sy-tabix.
at end of dept.
sum.
endat.
write : dept,,the amount field.
endloop.
Cheers,
Ravi
‎2007 May 11 12:44 PM
thanks for reply,
actually m using ALV. so i cant have write stmt.
‎2007 May 11 12:52 PM
Thats cool..i thought u r displaying in normal report format...
For ALV...
try this..
Sort it_xyz by Dept.
loop at it_xyz.
it_xyz-sno = sy-tabix.
modify it_xyz index sy-taix transporting sno.
endloop.
Then ur sno values will not be changed ..right???
‎2007 May 11 12:37 PM
Hi,
While building th fieldcatalog for the ALV,
Do follwoing:
LOOP AT T_FIELDCAT.
IF FIELDNAME = 'DEPARTMENT'.
T_FIELDCAT-DO_SUM = 'X'.
MODIFY T_FIELDCAT INDEX sy-tabix.
ENDIF.
This will automatically display the subtotal acoording to the departments.
Regards,
Himanshu
‎2007 May 11 12:47 PM
What is the Serial no doing there??
build a sort table on department and pass it_sort to REUSE_ALV_GRID_DISPLAY
it_sort-fieldname = 'DEPT'.
it_sort-up = 'X'.
it_sort-subtot = 'X'.
append it_sort.pass it_sort to REUSE_ALV_GRID_DISPLAY