‎2009 Apr 09 2:41 PM
Hi Experts,
I have requirement in report to add the values in the internal table based on document no.
for example
Document no date Amount Exchange Rate
190000012 05.04.2009 100 1
190000012 05.04.2009 200 1
190000012 05.04.2009 300 1
190000013 05.04.2009 100 1
190000013 05.04.2009 200 1
190000014 05.04.2009 100 1
If i use Collect or On change statements , the exchange rate is also adding
Document no date Amount Exchange Rate
190000012 05.04.2009 600 3
190000013 05.04.2009 300 2
190000014 05.04.2009 100 1
But i want to add only the amount field not the exchange rate .Please suggest me the best solutions.
I want to display as
Document no date Amount Exchange Rate
190000012 05.04.2009 600 1
190000013 05.04.2009 300 1
190000014 05.04.2009 100 1
Thanks in advance
satish
‎2009 Apr 09 2:46 PM
Define the exchange rate as char in your internal table and keep doing COLECT.
Issa
‎2009 Apr 09 2:49 PM
HI ,
Collect statement will add the all interger fields, So better declare the exchange rate field as the CHAR .
Regards,
Bharani
‎2009 Apr 09 2:50 PM
Try this logic it will work.Itab and Itab2 are of same structure.
Sort itab by documentno.
Loop at itab.
itab2-total = itab2-total + itab-total.
Move : itab-documentno to itab2-documentno,
itab-date to itab2-date,
itab-exchange to itab2-exchange.
AT END OF documentno.
append itab2.
clear itab2-total.
ENDAT.
Endloop.Regards,
Gurpreet
‎2009 Apr 09 2:58 PM
You can use COLLECT statement
if you are using at end control statement then make sure document number if your first field.
or what you can do is apply this logic!
tempdocno like itab-documentno.
Sort itab by documentno.
Loop at itab.
if itab-documentno eq tempdocno or sy-tabix eq 1. " check this if and endif.
itab2-total = itab2-total + itab-amount.
itab2-documentno = itab-documentno.
itab2-date = itab-date.
itab2-exchange = itab-exchange.
else.
append itab2.
clear itab2-total.
endif.
tempdocno = itab-documentno.
Endloop.Regards,
Lalit Mohan Gupta.
‎2009 Apr 09 3:10 PM
hi,
check this
Sort itab by documentno.
Loop at itab1.
on change of itab1-dcno.
clear total.
move itab1-docno to itab2-docno.
itab2-total = itab-amont.
move itab1-total to itab2-total.
move itab1-date to itab2-date.
move itab1-rate to itab2-rate.
flag = ' '.
append itab2.
clear itab2.
else.
itab2-total = itab2-total + itab-amont.
endon
Endloop.
it will work for adjest append statement according to the out put .
~linganna
‎2009 Apr 09 3:13 PM
Hi Experts,
Thanks a lot for your suggestions. It is solved.
Regards,
Satish