‎2007 Mar 08 6:58 AM
hi everybody...can we add two currency fields of a table...also we have to display the output of the total..if so could any one tell me the code....thnks in advance...
santosh...
‎2007 Mar 08 7:07 AM
Hi Santosh,
We can add the two fields as asked by you. Use the collect statement to sum all the required fields after passing the fields into the internal table.
Reward if helpful.
Regards
‎2007 Mar 08 8:27 AM
hi, thanx for ur answer...actuallly i have to fetch fwbas and fwste from bset and need to add those two fields....result sholuld be displayed finally...if possible...can u give me the sample code for this....
‎2007 Mar 08 8:30 AM
data : begin of itab occurs 0,
fwbas like bset-fwbas,
fwste like bset-fwbas,
total like bset-fwbas,
end of itab.
select fwbas fwste from bset into corresponding fields of table itab where....
loop at itab.
itab-total = itab-fwbas + itab-fwste.
modify itab.
<or you can write here>
endloop.
regards
shiba dutta
‎2007 Mar 08 8:47 AM
Hi santosh,
is this what you are looking for?
TABLES:BSET,
BKPF.
DATA:begin of itab occurs 0,
bukrs like BSET-BUKRS,
BELNR like BSET-BELNR,
GJAHR like BSET-GJAHR,
BUZEI like BSET-GJAHR,
FWBAS like BSET-FWBAS,
FWSTE like BSET-FWSTE,
tot like BSET-FWBAS,
waers like BKPF-WAERS,
end of itab.
select bukrs BELNR GJAHR BUZEI FWBAS FWSTE
into corresponding fields of table itab
from BSET where GJAHR = '2007'..
loop at itab.
itab-tot = itab-FWBAS + itab-FWSTE.
modify itab.
endloop.
loop at itab.
write:/ itab-tot.
endloop.
if you face problem in displaying in ALV, retrieve currency from BKPF table.
regards,
sap fan
‎2007 Mar 08 8:45 AM
data : begin of itab occurs 0,
fwbas type bset-fwbas,
fwste type bset-fwbas,
total type bset-fwbas,
end of itab.
select fwbas
fwste
from bset
into corresponding fields of table itab .
loop at itab.
itab-total = itab-fwbas + itab-fwste.
modify itab index sy-tabix.
endloop.