‎2007 Jul 11 2:59 AM
Hi all,
i have records like in internal table itab
id amount
101 1 1.00
101 2 2.00
102 1 1.00
102 2 2.50
102 3 3.00
103 2 1.50
i want the output like like this internal table itab1
101 3.00
102 6.50
103 1.50
clear : wa_zoritem ,price.
total= 0.00
loop at itab into wa_itab.
on change of wa_itab1-id.
clear total.
total= total + wa_itab1-amount.
wa_itab1-id = wa_itab_copy-id.
wa_itab1-total= wa_itab_copy-total.
append wa_itab1 to itab1.
endon.
*MODIFY TABLE i_FINAL FROM wa_FINAL
TRANSPORTING COST.
*MODIFY wa_final to i_final.
wa_itab_copy = wa_itab.
clear : wa_itab.
endloop.
This works fine when i have multiple records
but this doesn't work when i have the follwwing record in itab
id amount
101 1 1.00
Thanks
‎2007 Jul 11 3:03 AM
Hi,
clear : wa_zoritem ,price.
total= 0.00
loop at itab into wa_itab.
total= total + wa_itab-amount.
wa_itab1-id = wa_itab-id.
wa_itab1-total= wa_itab-total.
on change of wa_itab-id.
append wa_itab1 to itab1.
clear total.
total= total + wa_itab-amount.
endon.
clear : wa_itab.
endloop.
Message was edited by:
Jayanthi Jayaraman
‎2007 Jul 11 3:03 AM
Hi,
clear : wa_zoritem ,price.
total= 0.00
loop at itab into wa_itab.
total= total + wa_itab-amount.
wa_itab1-id = wa_itab-id.
wa_itab1-total= wa_itab-total.
on change of wa_itab-id.
append wa_itab1 to itab1.
clear total.
total= total + wa_itab-amount.
endon.
clear : wa_itab.
endloop.
Message was edited by:
Jayanthi Jayaraman
‎2007 Jul 11 3:06 AM
Hi Kajol,
Try this
loop at itab into wa_itab.
<b>if sy-tabix = 1.
total= total + wa_itab1-amount.
endif.</b>
on change of wa_itab1-id.
clear total.
total= total + wa_itab1-amount.
Regards,
Atish
‎2007 Jul 11 5:28 AM
hi,
*suppose the data is avialble in the internal table ITAB.
[code]
sort ITAB by ID amount.
delete adjacent duplicates from ITAB comparing ID.*Now thw ITAB conatins only the records.
*101 3.00
*102 6.50
*103 1.50[/code]
Regards
Reshma
‎2007 Jul 11 6:06 AM
data: itab2 like table of itab1 with header line.
loop at itab1.
move:; <col1> to itab2-<col1>
move: <col2> to itab2-<col2>
collect itab2.
clear itab2.
endloop.
or u can collect the itab1 itself but the values in the second field will get summed up.
if its not a probs u can do the same method in itab1.
‎2007 Jul 11 6:21 AM
Hi,
Either use collect statement
or
loop at itab
if id is same as previous
add the two id's and delete record from table.
Regards,
Sooness