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

Problem in using COLLECT statment

satish_kumar127
Participant
0 Likes
1,201

Hi experts,

getting problem in using COLLECT statement.  attaching my code below.

LOOP AT it_final1 INTO wa_final1.


     LOOP AT it_final INTO wa_final WHERE vagrp = wa_final1-vagrp AND verwmerkm = wa_final1-verwmerkm.

       wa_final1-anzwertg = wa_final-anzwertg.


       COLLECT wa_final1 INTO it_final1.

     ENDLOOP.

     CLEAR: wa_final1, wa_final.

   ENDLOOP.


here , i want to use collect statement only for  "anzwertg" field from internal table. but 2 more fields also getting  compressed .

attaching screen shot



here, original_input and max fields also getting compressed.

could anybody please help me out in this.

Thanks in advance.

Regards

satish

8 REPLIES 8
Read only

Former Member
0 Likes
1,157

Hi Satish,

All numeric fields are summed up in Collect statement if all the character fields are same.

thx

Read only

0 Likes
1,157

thank you narayana

Read only

pavanm592
Contributor
0 Likes
1,157

Hi,

Make sure original_input and max fields are charecter types,

revert if any issues after changing those to charecter fields

Regards

Pavan

Read only

0 Likes
1,157

hi pavan,

I've given those types are P decimals 2. without changing the type , can we achieve this?

Thanks & Regards

satish

Read only

Former Member
0 Likes
1,157

Hi,

The floating point fields are also added in collect statement. So you have to loop through the table and add the field required on your own.

Regards,

Aswath.

Read only

satish_kumar127
Participant
0 Likes
1,157

problem solved. thank u guys for your prompt reply and I am really happy with your knowledge transfer.

Read only

vamsilakshman_pendurti
Active Participant
0 Likes
1,157

Hi satish....

collect statement works based on char fields..

by default it will taken char fields as a key fields .........

if any char field is repeated then corresponding numc values will be added....

other wise it will act as a APPEND statement......

Here in ur code there is no char field then how it will caliculate that values...

just check it once..

Regards,

Vamsi....

Read only

0 Likes
1,157

yes vamsi, you are right, i found the solution. thanks for the KT.

regards

satish