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 Collect

Former Member
0 Kudos

Dear all

I have one internal table it_data with following data. And I want to Integrate this table by keeping

one entry for the same ARTNR by Collecting VVVOL3 VVVOL2 and VVVOL1

Now it_data is :-


ARTNR	VVVOL3	VVVOL2	VVVOL1
1010371	60	0	0
1010371	0	800	0
1010371	0	0	100
1012376	16	0	0
1012377	80	0	0
3200853	0	40	0

It should be :-


ARTNR	VVVOL3	VVVOL2	VVVOL1
1010371	60	800          100
1012376	16	0	0
1012377	80	0	0
3200853	0	40	0

COLLECT is not serving my purpose..because I want to modify the same internal table......

Could anybody suggest a solution ?

Thanksssssssssss.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Before the loop use SORT it_data by ARTNR.

Also make sure the fields VVVOL3 VVVOL2 and VVVOL1 are of type numeric.

8 REPLIES 8

Former Member
0 Kudos

Before the loop use SORT it_data by ARTNR.

Also make sure the fields VVVOL3 VVVOL2 and VVVOL1 are of type numeric.

Former Member
0 Kudos

Hi,

Collect can add only interger type fileds.

OR

Try this

SOrt irab by artnr.
Loop At itab.

itab1-artnr = itab-artnr.
itab1-VVVOL3 = itab1-VVVOL3 + itab-VVVOL3 .
itab1-VVVOL2 = itab1-VVVOL2 + itab-VVVOL2.
itab1-VVVOL1 = itab1-VVVOL1 + itab-VVVOL1.

AT END OF ARTNR.
Append itab1.
clear itab1.
ENDAT.
Endloop.

kamesh_g
Contributor
0 Kudos

hi

First sort the internaltable by ATRNR and all fields should be numeric and this numeric condition is exception for Material .. if internal table contains material you can use collect by material number this is only exception for material number ..

Former Member
0 Kudos

hi for use collect statement you must have a CHAR field in your internal table.

because it adds the numeric value for that char field which have same value.

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi,

You can start with the original internal table, collect in another internal table. Delete the contents of the original internal table and copy the contents of the collected internal table to the original internal table.

Something like this :



loop at itab into wa.

 collect wa into itab_new.

endloop.

delete itab.

itab = itab_new[].

regards,

Advait

Former Member
0 Kudos

Hi Ubhaka,

Try it this way:

sort it_data by artnr.
    loop at it_data into wa_data.
       at end of artnr.
         sum.
         wa_data1-VVVOL1 =  wa_data-VVVOL1.
         wa_data1-VVVOL2 =  wa_data-VVVOL2.
         wa_data1-VVVOL3 =  wa_data-VVVOL3.
         append wa_data1 to it_data1.         " final table
       endat.
    endloop.

With luck,

Pritam.

Former Member
0 Kudos

issue resolved ..thanks for ur reply........