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: 

Abap Query - Delete duplicates

Former Member
0 Kudos

I

I'm doing an abap query in SQ02 with LIKP and LIPS tables.

As output I just want lines with different entries in LIPS of material.

How can I delete the duplicates? With instruction delete ADJACENT DUPLICATES FROM XXXX COMPARING vbeln matnr, how can I identity the table?


Thanks

Dora

1 ACCEPTED SOLUTION

jogeswararao_kavala
Active Contributor
0 Kudos

Hello Dora,

It is a very well known difficult task to use 'Delete Adjacent Duplicates' syntax in Infoset Query because of the fact that you are not aware of the internal table.

Two methods to address this:

1. Study the repeating lines and use another suitable join in the tables manually, which can eliminate the undesirable duplicates.

2. The other one I always practiced was, Study all fields of the repeating lines. Identify at least one the field value which is not same in these duplicate lines. Suppose you have a field ABCD and values X in one and Y in other. And you have decided to have the lines with value X. Then give the following syntax in the Record Processing section of SQ02.

CHECK TABLE-ABCD = 'X'. 


This would remove the lines with Y.

KJogeswaraRao

8 REPLIES 8

Shiva_Ram
Active Contributor
0 Kudos

First of all why duplicate comes, did you check the query input parameters?

If you still want to add coding, then put your question in ABAP forum for answers.

Regards,

0 Kudos

Hi Dora

For removing duplicate you need to fetch data into some internal table and then apply

delete adjacent clause.

Syntax for this

DELETE ADJACENT DUPLICATES FROM itab comparing f1 f2 f3.

Here f1 f2 and f3 are list of fields.

Thanks,

Neha

Lakshmipathi
Active Contributor
0 Kudos

Moved from SAP ERP SD Billing to ABAP Development

G. Lakshmipathi

jogeswararao_kavala
Active Contributor
0 Kudos

Hello Dora,

It is a very well known difficult task to use 'Delete Adjacent Duplicates' syntax in Infoset Query because of the fact that you are not aware of the internal table.

Two methods to address this:

1. Study the repeating lines and use another suitable join in the tables manually, which can eliminate the undesirable duplicates.

2. The other one I always practiced was, Study all fields of the repeating lines. Identify at least one the field value which is not same in these duplicate lines. Suppose you have a field ABCD and values X in one and Y in other. And you have decided to have the lines with value X. Then give the following syntax in the Record Processing section of SQ02.

CHECK TABLE-ABCD = 'X'. 


This would remove the lines with Y.

KJogeswaraRao

0 Kudos

Hi, thanks for your answer.

The good of your answer is that now I know that this is not a simple question.

I can do sort the data before the Record Processing?


Thanks


Dora

0 Kudos

Again, the internal table figures in your question. So the answer is 'No'.

0 Kudos

Hi, my problem is that:

I have an header table and an item table.

I want the output with just 1 line for each entry for document/material.

EX: Doc A - Material 1

     Doc A - Material 2

     Doc A - Material 1

I want the output with just 2 lines:

     Doc A - Material 1

     Doc A - Material 2

I can stay with the last document/material and compare and if is the next is the same I can make a ' check ' as you say.

But if the lines don't came in order this is not going to work.

There are any way of compare with the lines that as already been process?

Thanks

Dora

0 Kudos

The solutions for the problem:

I create an internal table.

Then with an additional field I verify if that record already exists. Then I check if doesn't exists inserts in the internal table.