‎2008 Mar 27 1:24 PM
hello,
i need to do following ...
docno item bwart quantity
1 10 101 1
1 10 101 1
1 20 101 2
1 20 101 2
i need
docno item bwart quant
1 10 101 2
1 20 101 4
‎2008 Mar 27 1:26 PM
‎2008 Mar 27 1:32 PM
As it is an internal table make the first three fields as character and use COLLECT statement on them.
regards
sandeep
‎2008 Mar 27 1:33 PM
loop at itab.
v_quantity = v_quantity + itab-quantity.
at end of docno.
read table itab index sy-tabix.
write 😕 itab-docno,
itab-item,
itab-bwart,
v_quantity.
clear : v_quantity.
endat.
endloop.
‎2008 Mar 27 1:48 PM
sort the table according to first three fields and
on chage of docno item bwart
sum up the quantity by means of a temporary field and append them in new table of same structure
reward if helpful
‎2008 Mar 27 1:54 PM
‎2008 Mar 27 2:09 PM
‎2008 Mar 27 2:05 PM
Hi,
You can use collect statement as item, docno and bwart are of char type.
"Create a work area and internal table same as internal table.
loop at itab into wa.
collect wa into new_tab.
endloop.
Thanks,
Sriram Ponna.
‎2008 Mar 27 2:21 PM
Hi,
The COLLECT statement will give you the solution.Use the command as follows.
select * from makt .
collect itab.
endselect.
Regards,
Sankar.
‎2008 Mar 27 2:22 PM
You can do something like this.
you can copy your first internal table (FIT)to new internal table (SIT) then sort SIT and use delete command comparing all field to your SIT. now your SIT is like Primary key which has only one row of unique data. copy SIT to TIT, Now loop it, the top loop SIT with check condition like If all the field are same with FIT. if the condition is true move quantity field of FIT-quanity to temp variable. at the end of first endloop use read command then modify the TIT moving the temp field to TIT-quantity.
loop SIT
clear tmp.
loop FIT
check condition.
if sy-subrc = 0.
move FIT-quantaty to tmp.
endif.
endloop.
read table TIT .
if sy-subrc = 0.
move tmp to TIT-quantity.
clear tmp.
endif.
endloop.