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

Collect statement in Loop..

Former Member
0 Likes
4,361

Hi,

I have an Internal table ITAB with following records.

REC1 10

REC1 20

REC2 15

REC2 25

REC2 35

and I need an output

REC1 30

REC2 75

I tried like this

LOOP AT ITAB.

COLLECT ITAB.

MODIFY ITAB.

ENDLOOP.

Am i doing something wrong?? I am still getting 5 records in output..

regards

Praveen

1 ACCEPTED SOLUTION
Read only

venkata_ramisetti
Active Contributor
0 Likes
1,254

Hi Praveen,

You create another internal table with te same table type.

Then you write collect on the internal table.

define Itab1 like itab. and write logic like below.

LOOP AT ITAB.

ITAB1 = ITAB.

COLLECT ITAB1.

ENDLOOP.

Thanks,

Ramakrishna

2 REPLIES 2
Read only

venkata_ramisetti
Active Contributor
0 Likes
1,255

Hi Praveen,

You create another internal table with te same table type.

Then you write collect on the internal table.

define Itab1 like itab. and write logic like below.

LOOP AT ITAB.

ITAB1 = ITAB.

COLLECT ITAB1.

ENDLOOP.

Thanks,

Ramakrishna

Read only

Former Member
0 Likes
1,254

The below thread has the required code sample

Hope this solves your problem.

Regards

Kathirvel