2008 May 09 5:25 PM
I have one internal table.
its fields are
vbeln
posnr
brgew
gewei
volum
voleh
defined internal table as
DATA : BEGIN OF itab5 OCCURS 0,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
brgew LIKE vbap-brgew,
gewei LIKE vbap-gewei,
volum LIKE vbap-volum,
voleh LIKE vbap-voleh,
END OF itab5.
after some oerations on internal table i get some records in itab5
for each vbeln there may be motre than one posnr
for all posnr of one vbeln
i want subtotal of the field brgew and volum
i have coded this way
but it gets total of all vbelns
sort itab5 by vbeln .
loop at itab5.
on change of itab5-vbeln.
loop at itab5 where vbeln = itab5-vbeln.
sum.
endloop.
endon.
endloop.
pls suggest me the changes.
points will be rewarded to each.
I have one internal table.
its fields are
vbeln
posnr
brgew
gewei
volum
voleh
defined internal table as
DATA : BEGIN OF itab5 OCCURS 0,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
brgew LIKE vbap-brgew,
gewei LIKE vbap-gewei,
volum LIKE vbap-volum,
voleh LIKE vbap-voleh,
END OF itab5.
after some oerations on internal table i get some records in itab5
for each vbeln there may be motre than one posnr
for all posnr of one vbeln
i want subtotal of the field brgew and volum
i have coded this way
but it gets total of all vbelns
sort itab5 by vbeln .
loop at itab5.
on change of itab5-vbeln.
loop at itab5 where vbeln = itab5-vbeln.
sum.
endloop.
endon.
endloop.
pls suggest me the changes.
points will be rewarded to each.
2008 May 09 5:35 PM
hi,
try this:
sort itab5 by vbeln posnr.
loop ...
at end of posnr.
collect...
endat.
endloop.
2008 May 09 5:37 PM
Hello,
Do this,
data:
itab5_aux like itab5.
loop at itab5.
collect itab5 to itab5_aux.
endloop.
.
itab5_aux will have the sum.
Regards,
2008 May 09 7:26 PM
collect will work. but it has some restrictions(chck sap docu for this)..
effective solution for this is.
declare an internal itab and itab_fin table with fields:
vbeln
brgew
volum
loop at itab5.
move itab5-vbeln to itab-vbeln.
move itab5-brgew to itab-brgew.
move itab5-volum to itab-volum.
append itab.
endloop.
loop at itab.
collect itab into itab_fin.
endloop.
reward points if useful.
Thanks-
Harmeet.
2011 Feb 16 12:40 PM