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: 

finding count of duplicate values

Former Member
0 Kudos

hi gurus,

i have a situation where i need to find the count of dupliacted field values in an internal table . the scenario is like this

internal table 1 contains field1 with value x and the table2 contains field2 with repetaed  value x

                                                                                                                                      x

                                                                                                                                       x

now i want to count the repeated values of field2 in table2.

please note we have tried at changed on sysntax but not luck we want to acheive this in oo context.

Thanks

krishna.Y

5 REPLIES 5

koolspy_ultimate
Active Contributor
0 Kudos

hi just compare the two internal tables and use if condition and compare the two values.

If it is true increment the count value, and finally display the count value.

Hope your purpose will be solved.

Former Member
0 Kudos

Hi Krishna ,

  One possible solution can be as following.

Loop at table 1.

temp_table = table2.

delete temp_table where field2 <> table1-field1

no_of entry = lines( temp_table ).

endloop.

Regards

Arun

0 Kudos

not bad, but if the field is not numeric I would rather use FIND IN TABLE ... MATCH COUNT

naveen_inuganti2
Active Contributor
0 Kudos

loop at first table.

  loop at second table where field2 = field1 or 'X'.

   count = count + 1.

  endloop.

copy count...to other target or table field.

clear count.

endloop.

Regards,

Naveen.I

Former Member
0 Kudos

Hi Krishna,

According to your scenario we can say that fild2 of table2 is foreign key which points or references to the unique key(may be primary key)  field1 of table1.

So I think you can create view using these two tables.

then use following query.

select field1 count(field1) from view into internal_table group by field1.

loop at internal_table.

write:  internal_table-field1   , internal_table-count.

endloop.

you will get repeated value by  internal_table-count  field.