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 with index

Former Member
0 Likes
689

Hi

can anyone give me some idea how to use collect statement with index

here in the below syntax i want to use collect instead of insert.

INSERT WA_ALVDISPLAY INTO IT_ALVDISPLAY index 3 .

thanks.

vivekk

Hi

can anyone give me some idea how to use collect statement with index

here in the below syntax i want to use collect instead of insert.

INSERT WA_ALVDISPLAY INTO IT_ALVDISPLAY index 3 .

thanks.

vivekk

4 REPLIES 4
Read only

Former Member
0 Likes
614

I don't see that this makes any sense. Collecting and inserting are two different things.

Rob

Read only

HermannGahm
Product and Topic Expert
Product and Topic Expert
0 Likes
614

Hi,

why would you want to use the collect with an index? Do you know what a collect

is suppossed to do and how it works? If so, for what purpose would you need an

index addition?

Kind regards,

Hermann

Hi

>

> can anyone give me some idea how to use collect statement with index

> here in the below syntax i want to use collect instead of insert.

>

> INSERT WA_ALVDISPLAY INTO IT_ALVDISPLAY index 3 .

>

> thanks.

> vivekk

Read only

0 Likes
614

hi

my scenario is like this

i need an yearly report of a examination held in a school based on month,each month they need report for girls and boys separately

the output format should be like this

month:marks( boys) marks( girls )

so i have created 3 internal tables suppose itab ,itab1,itab2.

itab1-month1

itab1-boy_sub1

itab1-boy_sub2

itab2-month2

itab2-girl_sub1

itab2-girl_sub2

itab -month1

itab -boy_sub1

itab -boy_sub2

itab -girl_sub1

itab -girl_sub2

first i am looping in itab1 and using COLLECT statement i am inserting data to itab (bez in a month more than one exam can happen)

i got boys mark in itab,then i need to put girls mark on the same row based on month

based on particular index i need to insert data, moreover i need to use COLLECT statement for getting the total of particular month

thanks

vivek

Read only

0 Likes
614

hello Vivek,

I believe your desired result will be available using COLLECT without worrying about the order of the rows.

Since Collect will only add up the values if month is same and insert a new entry if month is different (because you have only numeric fields other than month).

Loop at itab1.

move-corresponding itab1 to itab.

collect itab.

endloop.

Loop at itab2.

move-corresponding itab2 to itab.

collect itab.

endloop

Please ask if you have any query.

regards,

Diwakar