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

ALV

Former Member
0 Likes
672

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
606

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

5 REPLIES 5
Read only

Former Member
0 Likes
607

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

Read only

0 Likes
606

thanks for reply,

actually m using ALV. so i cant have write stmt.

Read only

0 Likes
606

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???

Read only

Former Member
0 Likes
606

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

Read only

Former Member
0 Likes
606

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