‎2007 Aug 03 5:30 PM
Hi , what is collect statement, can any one explain me with an example...
thanks in advance
‎2007 Aug 03 6:26 PM
Hi Praveen,
Collect statement inserts contents of a work area into an internal table if a record with same key combination does not exist. But, if the same key combination exists, it adds the values of its numeric components to the corresponding values of existing rows with the same key.
i.e. if your internal table contains
A 100
B 100
Now, if you try to collect C 100, your internal table will look like
A 100
B 100
C 100
Now, if you try to collect C 200, then your internal table will look like
A 100
B 100
C 300.
Reward points if the answer is helpful.
Regards,
Mukul
‎2007 Aug 03 5:31 PM
‎2007 Aug 03 5:34 PM
say u have 10 line items and u want to have common line items as such then u use collect statement.
say, internal table has material and quantity.
aaa 10
aaa 20
bbb 5
ccc 8
bbb 3
aaa 5
bbb 7
so, if u want only rows as
aaa qty
bbb qty
ccc qty
sort itab by material.
loop at itab.
itab1-material = itab-material.
itab1-qty = itab-qty.
collect itab1.
endloop.
so, itab1 will have
aaa 35
bbb 15
ccc 8
hope u understood the concept.
Reward Points...
‎2007 Aug 03 6:26 PM
Hi Praveen,
Collect statement inserts contents of a work area into an internal table if a record with same key combination does not exist. But, if the same key combination exists, it adds the values of its numeric components to the corresponding values of existing rows with the same key.
i.e. if your internal table contains
A 100
B 100
Now, if you try to collect C 100, your internal table will look like
A 100
B 100
C 100
Now, if you try to collect C 200, then your internal table will look like
A 100
B 100
C 300.
Reward points if the answer is helpful.
Regards,
Mukul
‎2007 Aug 03 7:10 PM
Hi Praveen,
collect stamets compares the non numerical fields and adds the corr numerical fields. simply
aa 12
ab 13
aa 15
aa 23
ac 21
ab 15
ac 10
after collect statement u wil get the o/p like this
aa 50
ab 28
ac 31
‎2007 Aug 03 11:22 PM
Hey thanks alot man,,, ill keep in touch with u in the future..
thank you