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: 

Duplicate records in Internal table

Former Member
0 Kudos

Hi All,

I want to find out the duplicate entry in the internal table. I have used,

Delete Adjacent duplicates from itab.

It is straight away deleting the record.

I want the user to correct that duplicate record.

May be some error message.

I have tried, with read,

Read table itab with key bzirk = itab-bzirk vkorg = itab-vkorg kunnr = itab-kunnr

matnr = itab-matnr comparing bzirk vkorg kunnr matnr.

But it's giving sy-subrc = 0 for the first record also.

Even, I have tried like, but it's giving syntax error.

Loop at itab where bzirk = itab-bzirk vkorg = itab-vkorg kunnr = itab-kunnr

matnr = itab-matnr.

Endloop.

Any method in case on Table control entries.

Thanks & Regards,

Kalyan Chandramouli

SAP Consultant

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Create a new internal table and assign the all the records of itab1 to itab2.

1.Sort Itab2.

2.delete adjacent duplicates.

3. loop at itab2.

loop at itab1 where <conditon you want....>

count = count + 1.

endloop.

if count GT 1.

append the iatb2 records for user correction....

endif.

endloop.

If the hint is useful… Say thanks by reward….

Regards,

Prabhu Rajesh

2 REPLIES 2

Former Member
0 Kudos

Hi,

Create a new internal table and assign the all the records of itab1 to itab2.

1.Sort Itab2.

2.delete adjacent duplicates.

3. loop at itab2.

loop at itab1 where <conditon you want....>

count = count + 1.

endloop.

if count GT 1.

append the iatb2 records for user correction....

endif.

endloop.

If the hint is useful… Say thanks by reward….

Regards,

Prabhu Rajesh

Former Member
0 Kudos

data it_dupl...

if bzirk ne 0.

it_dupl[] = itab[].

delete adjacent duplicats from it_dupl.

if sy-subrc = 0.

message e111(zs1) 'Duplicate Record!'.

endif.

endif.