‎2006 Nov 01 9:43 PM
Hello Experts,
I need to sum up the values of an internal table record.
data: l_demand type p decimals 2.
The itab is:
MATNR DEMAND
....................
A005 100.00
A005 200.00
A005 300.00
A005 450.00
A005 325.00
Now I would want to get the sum of all values "DEMAND" into variable "l_demand".
Can you please tell me how can I do that?
Thanks.
‎2006 Nov 01 9:45 PM
Hi,
Try this..
LOOP AT ITAB.
AT LAST.
SUM.
L_DEMAND = ITAB-DEMAND.
ENDAT.
ENDLOOP.
WRITE: / L_DEMAND.
Thanks,
Naren
‎2006 Nov 01 9:45 PM
Hi,
Try this..
LOOP AT ITAB.
AT LAST.
SUM.
L_DEMAND = ITAB-DEMAND.
ENDAT.
ENDLOOP.
WRITE: / L_DEMAND.
Thanks,
Naren
‎2006 Nov 01 9:48 PM
Hi,
You can also code like this.
LOOP AT ITAB.
L_DEMAND = L_DEMAND + ITAB-DEMAND
ENDLOOP.
WRITE: / L_DEMAND.Regards,
Ferry Lianto
‎2006 Nov 01 10:04 PM
‎2006 Nov 01 10:36 PM
Hi
LOOP AT ITAB FROM 1
TO 12.
L_DEMAND = L_DEMAND + ITAB-DEMAND.
ENDLOOP.
Max
‎2006 Nov 01 10:34 PM
Hi,
Try this..Exit out of the loop if the current row is greater than 12.
LOOP AT ITAB.
IF SY-TABIX > 12.
EXIT.
ENDIF.
L_DEMAND = L_DEMAND + ITAB-DEMAND.
ENDLOOP.
WRITE: / L_DEMAND.
Thanks,
Naren
‎2006 Nov 01 11:02 PM
Hi,
Please remember to award points for helpful answers..
Thanks,
Naren
‎2006 Nov 01 11:47 PM