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 entries

Former Member
0 Likes
685

Please go to the following website:-

http://help.sap.com/saphelp_nw04/helpdata/en/06/aafd54fc4011d195280000e8353423/content.htm

and please scroll down to find:-

<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].

Then please go to the last example where the code is written as :-

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS.

IS THIS CORRECT ?

Regards

abaper.learner

1 ACCEPTED SOLUTION
Read only

varma_narayana
Active Contributor
0 Likes
636

Hi

The Correct version is:

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS.

OR....

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING COL1.

the Otherone may be Mistake in SAP DOCu...

<b>reward if Helpful</b>

4 REPLIES 4
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
636

Hi,

YES, there is no problem with the statement

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS

<b>ENTRIES is wrongly mentioned in the syntax, its not part of the DELETE syntax.</b>

Regards,

Sesh

Read only

varma_narayana
Active Contributor
0 Likes
637

Hi

The Correct version is:

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS.

OR....

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING COL1.

the Otherone may be Mistake in SAP DOCu...

<b>reward if Helpful</b>

Read only

former_member404244
Active Contributor
0 Likes
636

Hi,

The statement DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS.

it is correct.

Regards,

Nagaraj

Read only

Former Member
0 Likes
636

Hi learner,

<b>Deleting a sequence of lines</b>

DO 101 TIMES.

DELETE TAB_DEST INDEX 450.

ENDDO.

DELETE TAB_DEST FROM 450 TO 550.

<b>Deleting a set of lines</b>

LOOP AT TAB_DEST

WHERE K = KVAL.

DELETE TAB_DEST.

ENDLOOP

DELETE TAB_DEST WHERE K = KVAL.

<b>DELETE ADJACENT DUPLICATES</b>

As with the ORDER BY clause it could be better to avoid using SELECT DISTINCT, if some of the fields are not part of an index. Instead use ABAP SORT + DELETE ADJACENT DUPLICATES on an internal table, to delete duplicate rows.

LOOP AT TAB1.

READ TABLE TAB2 INDEX SY-TABIX.

IF TAB1 <> TAB2.

TAB_DIFFERENT = 'X'. EXIT.

ENDIF.

ENDLOOP.

ENDIF.

IF TAB_DIFFERENT = SPACE. " ...

ENDIF.

IF TAB1[] = TAB2[]. " ...

ENDIF.

Regards,

Kumar.