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

internal table

Former Member
0 Likes
799

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

9 REPLIES 9
Read only

Former Member
0 Likes
782

search the form this has been soved a a thousand times

Read only

0 Likes
782

As it is an internal table make the first three fields as character and use COLLECT statement on them.

regards

sandeep

Read only

Former Member
0 Likes
782

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.

Read only

Former Member
0 Likes
782

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

Read only

Former Member
0 Likes
782

hi Florian

can u plz provide the link

Read only

0 Likes
782

Read only

Former Member
0 Likes
782

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.

Read only

Former Member
0 Likes
782

Hi,

The COLLECT statement will give you the solution.Use the command as follows.

select * from makt .

collect itab.

endselect.

Regards,

Sankar.

Read only

0 Likes
782

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.