2009 Jun 30 10:37 PM
Hi,
I want to know how to add different rows of a column in an internal table.
My code :
-
Declaration Part-----
types : begin of imchb,
clabs like mchb-clabs,
cumlm like mchb-cumlm,
cinsm like mchb-cinsm,
tot_val_stock type p decimals 3,
pm_percent type p decimals 6,
end of imchb.
data : int_inv type standard table of imchb with header line,
wa_inv like line of int_inv.
Then I do few calculations and display it in the column pm_percent.
Now I want to sum this column.
-
Summation---
loop
at int_inv into wa_inv.
at end of pm_percent.
sum.
endat.
endloop.
write 😕 wa_inv-pm_percent.
However , wa_inv-pm_percent only gives me the value of the last row of the column.
Kindly suggest .
Hi,
I want to know how to add different rows of a column in an internal table.
My code :
-
Declaration Part-----
types : begin of imchb,
clabs like mchb-clabs,
cumlm like mchb-cumlm,
cinsm like mchb-cinsm,
tot_val_stock type p decimals 3,
pm_percent type p decimals 6,
end of imchb.
data : int_inv type standard table of imchb with header line,
wa_inv like line of int_inv.
Then I do few calculations and display it in the column pm_percent.
Now I want to sum this column.
-
Summation---
loop
at int_inv into wa_inv.
at end of pm_percent.
sum.
endat.
endloop.
write 😕 wa_inv-pm_percent.
However , wa_inv-pm_percent only gives me the value of the last row of the column.
Kindly suggest .
2009 Jun 30 11:19 PM
Hi,
In your loop you have the statement "AT END"... I think that's the issue. Debug your code and check the value of that field.
2009 Jul 01 2:52 AM
If they are the quantity fields, try using the collect statement with in the loop.
2009 Jul 01 3:44 AM
Hi abilasa,
loop at int_inv into wa_inv.
collect wa_inv.
endloop.so, wa_inv-pm_percent will contain the total value.
but remember when doing the collect, the other fields in the internal table must be of character type and they should be like the key field.
let me know if your problem solves.
thanks,
Sakthi Sri.
2009 Jul 01 4:24 AM
Hi,
Please try this code:
loop at int_inv into wa_inv.
lv_count = lv_count + 1.
AT END OF posnr. <------- The field you want to sum..
gs_total-posnr = wa_inv-posnr.
gs_total-cov_total = lv_count.
APPEND gs_total TO gt_total.
CLEAR : gs_total,
lv_count,
wa_inv.
ENDAT.
ENDLOOP.
2009 Jul 01 5:08 PM
Hi ,
This seemed to do the trick.
loop at int_inv.
sum .
new-line.
endloop.
write 😕
'----
'.
write : /60 'The sum of precious metal (Gold Content)' , 105
int_inv-pm_percent.
Thanks for all your input.
2009 Jul 01 5:10 PM
2009 Jul 17 7:21 PM
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |