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

Internal table query

harish_padikkadmohananara
Product and Topic Expert
Product and Topic Expert
0 Likes
556

Hi,

I have a internal table with two columns c1 and c2.

I have three records r1,r2 and r3.These records are ,

A1 B1

A2 B2

A3 B3

Now i can have a record,

A1 B2

but not a record like,

A1 B1

again,so the duplication of the record need to be prevented.I need to know how to check for the duplication of existing records in the internal table with the newly added record.

Thank you.

Regards,

Harish

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
533

hi,

Use

DELETE ADJACENT DUPLICATES.

5 REPLIES 5
Read only

Former Member
0 Likes
534

hi,

Use

DELETE ADJACENT DUPLICATES.

Read only

0 Likes
533

Can you elaborate?Also will this not affect the performace when it comes to many number of records being handled?

Read only

0 Likes
533

You can use the READ TABLE statement to check for duplicate entries.


READ TABLE itab WITH KEY c1 = value1
                         c2 = value2.

IF sy-subrc eq 0.
" Duplicate records exist
ENDIF.

Please mark points if the solution was useful.

Regards,

Manoj

Read only

Former Member
0 Likes
533

SORT ITAB BY <C1> <C2> .

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING C1 C2.

IF SY-SUBRC EQ 0.

<implies there are duplicate entries and are deleted>.

ELSE.

<no duplicate entries>

ENDIF.

Regards,

Pavan

Read only

Former Member
0 Likes
533

Hi Harish,

SORT ITAB BY C1, C2.

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING C1 C2.

<b>

Regards,

Azhar</b>