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: 

Deleting Duplicate entries from Internal tbale

Former Member
0 Kudos

Hi All,

I have used this code to delete duplicate entries from an internal table.

DELETE ADJACENT DUPLICATES FROM IT_KOSTL COMPARING KOSTL hours.

After this statment, still the internal table will remain with a duplicate row.

Earlier table content before the delete statement:

Lno KOSTL PRCTR hours hours1

1 2081010205 0000208101 5525.000 1574.500

2 2081010105 0000208101 105162.000 73854.750

3 2081010105 0000208101 105162.000 73854.750

4 2081010205 0000208101 5525.000 1574.500

The Table gets modified after execution of DELETE statement as follows.

Lno KOSTL PRCTR hours hours1

1 2081010205 0000208101 5525.000 1574.500

2 2081010105 0000208101 105162.000 73854.750

3 2081010205 0000208101 5525.000 1574.500

Why the line 3 is still present in the table?

I hope as per that syntax, this line too should get delete.... Is it right?

Basically i would like to delete both line 3 and line 4 from....

How to resolve this issue?

Please help me out....

Regards

Pavan

What might be the reason?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Sort the internal table first.

I think you haven't used COMPARING <fields> addition thats why duplicate records are not getting deleted.

Regards

Abhijeet

12 REPLIES 12

Former Member
0 Kudos

Please post your entire code so we can take a look at it.

Sort it first. That will do the trick.

Former Member
0 Kudos

Hi,

Sort the internal table first.

I think you haven't used COMPARING <fields> addition thats why duplicate records are not getting deleted.

Regards

Abhijeet

0 Kudos

>

> I think you haven't used COMPARING <fields> addition thats why duplicate records are not getting deleted.

NO.

He used comparing fields:

DELETE ADJACENT DUPLICATES FROM IT_KOSTL COMPARING KOSTL hours.

God know what's was the problem apart from sorting and problem solved by giving random marks.

0 Kudos

Oops!

I didn't notice that. Anyways Thanks Amit for pointing out my mistake. Next time it won't happen.

0 Kudos

Ok. Good

Enjoy Posting.

Cheers

Former Member
0 Kudos

hii

first sort internal table then use DELETE statement.i hope it works.

regards

twinkal

0 Kudos

First sort on KOSTL and HOURS..and then delete

Former Member
0 Kudos

Hi

First sort your <itab> with key fields.

Then delete adjacent duplicate entries from <itab> comparing all fields.

hope this will work....

Former Member
0 Kudos

Hi

Use the below statement before your DELETE statement.

SORT IT_KOSTL BY KOSTL HOURS.

DELETE ADJACENT compares the adjacent records before deletion by comparing given fields, hence you have to sort internal table according to them before deletion.

Regards

Vijai

former_member181995
Active Contributor
0 Kudos

>

> DELETE ADJACENT DUPLICATES FROM IT_KOSTL COMPARING KOSTL hours.

> Why the line 3 is still present in the table?

>

> I hope as per that syntax, this line too should get delete.... Is it right?

>

Let me answer you all doubts.

Why the line 3 is still present in the table?

Actually it's not 3rd line, it's 2nd line.3rd line were deleted.

when delete adjecent duplicates trigger than it would delete lower line(3rd in your case) not upper line.

I hope as per that syntax, this line too should get delete.... Is it right?

NO.

Former Member
0 Kudos

sort the internal table by kostl and delete adjacent duplicates .

thank you,

govinda chary.

Former Member
0 Kudos

This message was moderated.