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

Sub Total

Former Member
0 Likes
612

Hai All,

I have an internal table with following fields

vbeln TYPE vbrk-vbeln,

kbetr TYPE konv-kbetr,

kawrt TYPE konv-kawrt,

agentcomm TYPE konv-kwert,

i want to find the sub total of KAWRT and agentcomm at change of vbeln and kbetr

Regards

Nausal

4 REPLIES 4
Read only

venkat_o
Active Contributor
0 Likes
573

Hi,

Try this way


DATA: BEGIN OF it_data OCCURS 0,
        vbeln TYPE vbrk-vbeln,
        kbetr TYPE konv-kbetr,
        kawrt TYPE konv-kawrt,
        agentcomm TYPE konv-kwert,
      END OF it_data.

*Get the data from tables
*sort it_data by vbeln kbetr
SORT it_data BY vbeln kbetr.

LOOP AT it_data.
  AT END OF vbeln.
    SUM." You will get sum here. Check it_data-kawrt
  ENDAT.
  AT END OF kbetr.
    SUM." You will get sum here. Check it_data-kawrt
  ENDAT.
ENDLOOP.

Thanks

Venkat.O

Read only

Former Member
0 Likes
573

Hope this may help you

 
sort i_itab by vbeln kbetr.
loop at i_itab into wa_itab.

ws_subtotal_kawrt = ws_subtotal_kawrt + wa_itab-kawrt.
ws_subtotal_agcom = ws_subtotal_agcom + wa_itab-agcom.

at end of kbetr
   write: ws_subtotal_kawrt ws_subtotal_agcom.
   clear ws_subtotal_kawrt ws_subtotal_agcom.
endat

endloop.

Thanks,

Muthu

Read only

Former Member
0 Likes
573

HI,

YOU MAY USE ON CHANGE OF ALSO,

sort itab by vbeln.

loop at ITAB into wa.

ON CHANGE OF VBELN

sum.

endon.

at end of vbeln

write kawrt.

endat.

endloop.

Read only

Former Member
0 Likes
573

using internal ables to find sub total by using at end of