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

Delete duplicate entry from an internal table

sudha_naik
Product and Topic Expert
Product and Topic Expert
0 Likes
1,406

hello,

I have an internal table which has the following data

101 Raju

102 Shyama

103 Rita

103 Rita

104 Usha

I want to delete the duplicate one for 103, Rita. "Delete adjacent duplicates" is deleting both the entries. I want to retain one entry. Please help

Thanks and Regards

Sudha Naik

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,379

Hello,

DO like this.

sort itab by feild1 field2.

<b>delete adjacent duplicates from itab comparing field1 field2</b>.

Vasanth

10 REPLIES 10
Read only

Former Member
0 Likes
1,380

Hello,

DO like this.

sort itab by feild1 field2.

<b>delete adjacent duplicates from itab comparing field1 field2</b>.

Vasanth

Read only

Former Member
0 Likes
1,379

Delete Adjuscant duplicates from Itab

Read only

Former Member
0 Likes
1,379

it will delete only one one entry , pls post ur code

sort itab by field1 field2.

delete adjacent duplicates from itab comparing field1 field2.

Message was edited by:

Chandrasekhar Jagarlamudi

Read only

Former Member
0 Likes
1,379

before using delete, use sort statement.

sort itab by field1 filed2.

delete adjacent duplicates from itab comparing field1 field2.

Read only

Former Member
0 Likes
1,379

Deleting programmatically

Create an exact replica of the int table say itab1 .

itab1[] = itab[] .

loop at itab .

read table itab1 with key f1 = itab-f1

f2 = itab-f2

fn = itab-fn .

if sy-subrc = 0 . " identical entry

delete itab .

endif .

~ Laxmi

  • Reward all helpful answers

Read only

Former Member
0 Likes
1,379

Hi,

First sort ur Internal table.

then use delete adjacent duplicates from that Internal table comparing Name.

It will comapre the internal table for any table duplicate entry if exits n then delete the one which has a repeatiton.

Regards ,

Asish Dash

Read only

Former Member
0 Likes
1,379

HI,

Loop the itab where name = rita.

Modify itab.

endloop.

Regards,

Nandha

Reward if it helps

Read only

Former Member
0 Likes
1,379

Hi,

Try with this code:

data: begin of line,

col1 type i,

col2(5) type c,

end of line.

data: itab like standard table of line.

line-col1 = 101. line-col2 = 'Raju'. append line to itab.

line-col1 = 102. line-col2 = 'Shyama'. append line to itab.

line-col1 = 103. line-col2 = 'Rita'. append line to itab.

line-col1 = 103. line-col2 = 'Rita'. append line to itab.

line-col1 = 104. line-col2 = 'Usha'. append line to itab.

write 'Before delete'.

loop at itab into line.

write: / line-col1, line-col2.

endloop.

write:/ 'After delete'.

delete adjacent duplicates from itab.

loop at itab into line.

write: / line-col1, line-col2.

endloop.

Regards,

Bhaskar

Read only

sudha_naik
Product and Topic Expert
Product and Topic Expert
0 Likes
1,379

Thanks a lot all of you for your prompt answers

Read only

sudha_naik
Product and Topic Expert
Product and Topic Expert
0 Likes
1,379

Thanks a lot all of you for your prompt answers