Application Development 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: 

Problem in using COLLECT statment

satish_kumar127
Participant
0 Kudos
210

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

Former Member
0 Kudos
166

Hi Satish,

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

thx

0 Kudos
166

thank you narayana

pavanm592
Contributor
0 Kudos
166

Hi,

Make sure original_input and max fields are charecter types,

revert if any issues after changing those to charecter fields

Regards

Pavan

0 Kudos
166

hi pavan,

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

Thanks & Regards

satish

Former Member
0 Kudos
166

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.

satish_kumar127
Participant
0 Kudos
166

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

vamsilakshman_pendurti
Active Participant
0 Kudos
166

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....

0 Kudos
166

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

regards

satish