Application Development 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: 

performing calculations from internal table

Former Member
0 Kudos

hi folks,

I have the question. Here is the code..

types: begin of balfw,

kunnr type bseg-kunnr,

zuonr type bseg-zuonr,

wrbtr type bseg-wrbtr,

types: end of balfw.

data: balfwitab type standard table of balfw

with header line.

zbalanceamount type bseg-wrbtr.

select kunnr zuonr wrbtr into table balfwitab

where bseg-kunnr = p_custid.

if bseg-kunnr = bseg-zuonr.

loop balfwitab into bwa

move bwa-wrbtr into zbalanceamount.

....

I will have to read the data from the field 'wrbtr' -amount field(currency data type) from the itab

and need to add each value as I loop each time and store it in a separate variable .

Then I need to save that data into a separate variable of char type because I need to insert this data into another itable where this field is of character data type.

How can I do this?

Thanks in advance

Santhosh

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos


  clear zbalanceamount.
  loop balfwitab into bwa.
    add bwa-wrbtr to zbalanceamount.
  endloop.
  
  
*  zbalanceamount now has the total and can be added
*  to your new internal table.

Regards,

Rich Heilman

4 REPLIES 4

athavanraja
Active Contributor
0 Kudos

loop balfwitab into bwa

zbalanceamount = zbalanceamount + bwa-wrbtr .

endloop .

data: charamount(20) type c .

write zbalanceamount to charamount .

Regards

Raja

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos


  clear zbalanceamount.
  loop balfwitab into bwa.
    add bwa-wrbtr to zbalanceamount.
  endloop.
  
  
*  zbalanceamount now has the total and can be added
*  to your new internal table.

Regards,

Rich Heilman

Former Member
0 Kudos

Bear in mind that bseg-wrbtr is unsigned. You have to check the debit/credit indicator bseg-shkzg.


if bseg-shkzg = 'H'.
* process credit
else.
* process debit
endif.

Add or subtract depending on how you show debits/credits.

Rob

And you shouldn't select BSEG on anything but the key fields. For customers, use BSID and BSAD instead, depending on whether you want open and/or closed items.

Message was edited by: Rob Burbank

0 Kudos

thanks a lot it really helped.