Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

adding two numeric fields

Former Member
0 Likes
634

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...

5 REPLIES 5
Read only

Former Member
0 Likes
590

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

Read only

0 Likes
590

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....

Read only

0 Likes
590

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

Read only

0 Likes
590

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

Read only

Former Member
0 Likes
590

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.