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

duplicate records

Former Member
0 Likes
886

Hi all,

How to delete duplicate records of p.o. while checking with kunnr, vkorg, vtweg, bstkd, bstdk respectively.

Do the Needful.

Thanks in advance

Venkat

Hi all,

How to delete duplicate records of p.o. while checking with kunnr, vkorg, vtweg, bstkd, bstdk respectively.

Do the Needful.

Thanks in advance

Venkat

6 REPLIES 6
Read only

Laxmana_Appana_
Active Contributor
0 Likes
847

Hi,

if your data is in a internal table i_tab , then sort and use the below statement :

sort i_tab by kunnr vkorg vtweg bstkd bstdk

delete adjacent duplicates from i_tab comparing kunnr vkorg vtweg bstkd bstdk

syntax :

Extras:

1. ... COMPARING f1 f2 ...

2. ... COMPARING ALL FIELDS

Effect

Deletes adjacent duplicate entries from the internal table itab. If there are n duplicate entries in succession, the first entry is retained, and the following n-1 entries are deleted.

Two lines are regarded as duplicates if their keys are identical.

The Return Code is set as follows:

SY-SUBRC = 0:

At least one duplicate was found, and at least one entry was deleted.

SY-SUBRC = 4:

No duplicates found, no entries deleted.

Addition 1

... COMPARING f1 f2 ...

Effect

Two lines of the internal table itab are regarded as duplicates if they have identical contents in the fields f1, f2, ...

Addition 2

... COMPARING ALL FIELDS

Effect

Two lines of the internal table are regarded as duplicates if all of their field contents are identical.

Regards

appana

Read only

Simha_
Product and Topic Expert
Product and Topic Expert
0 Likes
847

Hi,

Just sort the internal table and then use the statement delete adjacent from itab comparing field names...

sorting is must...

Cheers,

Simha.

Read only

Manohar2u
Active Contributor
0 Likes
847

<b>Deleting Adjacent Duplicate Entries</b>

To delete adjacent duplicate entries use the following statement:

DELETE ADJACENT DUPLICATE ENTRIES FROM <itab>

[COMPARING <f1> <f 2> ...

|ALL FIELDS].

So you can try as

DELETE ADJACENT DUPLICATE ENTRIES FROM ITAB COMPARING KUNNR VKORG VTWEG BSTKD BSTDK.

Go thhru this link

http://help.sap.com/saphelp_47x200/helpdata/en/06/aafd54fc4011d195280000e8353423/frameset.htm

Regds

Manohar

Read only

Former Member
0 Likes
847

Hi Venkat,

Before deleting duplicate records, sort the internal table according to your needs. What fields you are going to sort.

Then user adjacent duplicates statement.

Regards

Arun

Read only

Former Member
0 Likes
847

Hi Venkat,

First you sort your internal table by kunnr, vkorg, vtweg, bstkd, bstdk

then use the following syntax

DELETE ADJACENT DUPLICATE ENTRIES FROM <itab>

[COMPARING <f1> <f2> |ALL FIELDS].

Giridhar..

Read only

muhammed_nishad
Participant
0 Likes
847

HAI,

to delete duplicate records.i suppose there are you ways.

One: not to select the duplicate records .for that use the key word DISTINCT for selecting multiple records.it will not select duplicate records.

Two:select all the records into a internal table.sort it ,then use 'DELETE ADJECENT DUPLICATES'.

please award points if it meets your requirement.

thank you.