2012 Jun 15 10:47 AM
Dear experts,
I am trying to sum a value in an internal table with the following code:
sort it_vbrp by matnr.
loop at it_vbrp.
at new matnr.
clear it_sqty.
endat.
it_sqty-matnr = it_vbrp-matnr.
it_sqty-slqty = it_sqty-slqty + it_vbrp-FKIMG.
at end of matnr.
append it_sqty.
endat.
endloop.
The problem is that it goes to the statement "append it_sqty." in every loop even though matnr is still the same.
Would you please let me know how to correct it?
Sincerely,
VT
Moderator Message: It is explained in SAP documentation, read it once. Thread Locked.
Message was edited by: Kesavadas Thekkillath
2012 Jun 15 11:00 AM
MATNR should be the first field in it_vbrp for this to work.
In your internal table say, if you have VBELN VBPOS MATNR, then AT END OF MATNR will be trigerred when one of these 3 fields change.
Check the documentation for At END of
Thanks,
Shambu
2012 Jun 15 11:02 AM
Hi,
When you keep the fields in a group the sort fields should be the first.Just check in debug mode.
Regards,
Madhu.