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

remove duplicate rows.

Former Member
0 Likes
16,876

Hi,

I want remove all the duplicate rows from internal table comparing all the fields. my internal table has following fields.

internal table -> it_final

partner.

industry.

is_competitor.

is_prospect.

is_consumer.

is_customer.

customer_since.

is_rented.

nielsen_id.

classific.

account_group.

I want to remove duplicates only if all the above fields have same data in a row and not a single field contains duplicate data.

Pls help

Regards,

Santosh

1 ACCEPTED SOLUTION
Read only

Former Member
5,613

Hi,

SORT IT_TAB BY partner industry is_competitor is_prospect is_consumer is_customer

customer_since is_rented nielsen_id classific account_group.

DELETE ADJACENT DUPLICATES FROM IT_ITAB COMPARING ALL FIELDS.

Regards,

Mon Magallanes

30 REPLIES 30
Read only

Former Member
0 Likes
5,613

Hello,

First sort the internal table by the key fields and then delete the duplicates.

SORT IT_TAB BY PARTNER INDUSTRY and so on.
DELETE ADJACENT DUPLICATES FROM IT_ITAB COMPARING ALL FIELDS.

Regards,

Shailaja

Read only

Former Member
0 Likes
5,613

Hi,

[]

[]

Read only

Former Member
0 Likes
5,613

Hi santosh,

You can use following to remove all duplicates..

DELETE ADJACENT DUPLICATES FROM it_final COMPARING ALL FIELDS.

Read only

Former Member
0 Likes
5,613

Hi,


Sort <internal table>.

DELETE ADJACENT DUPLICATES FROM  internaL TALBLE NAME COMPARING ALL FIELDS

HOPE IT WILL HELP YOU

THANKS

ARUN KAYAL

Edited by: Arun Kayal on Feb 4, 2009 6:55 AM

Read only

GauthamV
Active Contributor
0 Likes
5,613

I dont think you will get any such kind of scenarios where entire

record is same.

Anyhow use this for that purpose.

delete adjacent duplicates from itab comparing all fields.

Read only

Former Member
0 Likes
5,613

Hi,

Try like this....



Sort <internal table>.
delete adjacent duplicates from <internaltable> comparing all fields.

Hope it will helps

Read only

former_member222860
Active Contributor
0 Likes
5,613

Did U tried with

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS

Read only

Former Member
0 Likes
5,613

Hi Santosh,

There are many similar thread for the same issue in SCN.

Please search.

READ HELP ON DELETE ADJACENT DUPLICATES FROM itab.

Regards,

Nitin.

Read only

Former Member
0 Likes
5,613

Hi santhosh,

use

DELETE ADJACENT DUPLICATES FROM it_final COMPARING <field_name>

Read only

Former Member
0 Likes
5,613

DELETE ADJACENT DUPLICATES FROM itab comparing all fields

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
5,613

Hi,

Use:-

To delete comparing all fields.


sort itab by field1 field2 field3. "and so on for using all fields
delete adjacent duplicates from itab comparing all fields.

To delete comparing only one field


sort itab by field1.
delete adjacent duplicates from itab comparing field1.

Hope this solves your problem.

Thanks & Regards,

Tarun Gambhir

Read only

faisalatsap
Active Contributor
0 Likes
5,613

Hi,

Test the following Sample Code hope will solve out your problem,

TYPES: BEGIN OF t_test,
  s_number TYPE i,
  name1(10),
  name2(10),
END OF t_test.

data: it_test TYPE STANDARD TABLE OF t_test WITH HEADER LINE.

it_test-s_number = 1.
it_test-name1 = 'AAA'.
it_test-name2 = 'AAA'.
append it_test to it_test.

it_test-s_number = 2.
it_test-name1 = 'AAA'.
it_test-name2 = 'AAA'.
append it_test to it_test.

it_test-s_number = 2.
it_test-name1 = 'AAA'.
it_test-name2 = 'AAA'.
append it_test to it_test.

it_test-s_number = 3.
it_test-name1 = 'AAA'.
it_test-name2 = 'BBB'.
append it_test to it_test.

it_test-s_number = 4.
it_test-name1 = 'AAA'.
it_test-name2 = 'BBB'.
append it_test to it_test.

it_test-s_number = 5.
it_test-name1 = 'AAA'.
it_test-name2 = 'BBB'.
append it_test to it_test.

SORT it_test by s_number name1 name2.

DELETE ADJACENT DUPLICATES FROM it_test COMPARING ALL FIELDS.

\

Kind Regards,

Faisal

Read only

Former Member
0 Likes
5,613

hi,

According to my understanding of ur requirement u want to delete duplicate rows in every field.

say records are:

A LMN XYZ

AA PQR XYZ

then these records shd be deleted as field3 has duplicate entries.

internal table -> it_final

partner.

industry.

is_competitor.

is_prospect.

is_consumer.

is_customer.

customer_since.

is_rented.

nielsen_id.

classific.

account_group.

can do the following:

data:

t_fieldname type string occurs 10 with header line.

t_fieldname = 'PARTNER'.

append t_fieldname.

likewise append all the fieldnames into t_fieldname industry is_competitor so on....

sort it_final by partner industry is_competitor is_prospect is_consumer is_customer customer_since

is_rented nielsen_id classific account_group.

loop at t_fieldname.

delete adjacent duplicates from it_final comparing t_fieldname.

endloop.

it checks each field and deletes the adj duplicate rec.

Regards,

Mdi.Deeba Najam.

Read only

Former Member
0 Likes
5,613

Sort the internal table first based on the fields

and use delete adjascent command with the fields

Read only

Former Member
5,614

Hi,

SORT IT_TAB BY partner industry is_competitor is_prospect is_consumer is_customer

customer_since is_rented nielsen_id classific account_group.

DELETE ADJACENT DUPLICATES FROM IT_ITAB COMPARING ALL FIELDS.

Regards,

Mon Magallanes

Read only

0 Likes
5,613

Hi Santosh,

If you got to remove absolutely duplicate entries from an internal table,

first sort the table and

DELETE ADJACENT FROM IT_TAB COMPARING ALL FIELDS.

But in case, you do not have to delete the entries, but to avoid duplication of display, then either give AT NEW FIELDNAME within the LOOP, or use ON CHANGE OF IT_TAB-FIELDNAME.

Thankyou,

Zahack

Read only

Former Member
0 Likes
5,613

Hi,

You can achieve it by sorting the table with all the fields and delete adjacent duplicates .

SORT <table-name> by<field-name or mention all field names> .

DELETE adjacent duplicates FROM <table-name> comparing ALL fields.

Regards,

Rajani

Read only

0 Likes
5,613

Im blind, cant read and write properly and cant comprehend things that easily too. so im not sure if the question has been answered yet or not. so here is my answer:

I think what you need to do is SORT the internal table and then use the DELETE ADJACENT DUPLICATES statment on the internal table.

Im not really sure if this will solve your problem. You might want to wait for a few more replies to get a confirmation and then close the thread.

Please dont forget to do the needful too.

pk

Read only

0 Likes
5,613

My vote is also for deleting adjacent duplicates from the internal table comparing the fields which should be the same, and I also want to pay less taxes and those people living under the bridge near the railway station should be given a home and a warm blanket.

Next please...

Read only

0 Likes
5,613

In addition to the warm blanket, I want points baby, POINTS!!

Read only

matt
Active Contributor
0 Likes
5,613

>

> In addition to the warm blanket, I want points baby, POINTS!!

Do you want them urgently?

Read only

0 Likes
5,613

Hi Jerry,

If there are enough votes for "delete adjacent duplicates from i_tab comparing all fields", then I will take out a SAP Netweaver Subscription to become a Premium user, in which case I can award d o u b l e p o i n t s and will throw in a tin of bullybeef as well if you vote today still!

Don't fall for any short-term u r g e n t 2 -point promises!

Cheers,

Julius

Read only

0 Likes
5,613

Who is assigning these points remove the points and delete the question?:)

Read only

0 Likes
5,613

That would be very undemocratic..

Read only

0 Likes
5,613

SORT forum BY garbage.
DELETE ADJACENT DUPLICATES FROM forum COMPARING garbage.
Read only

0 Likes
5,613

SORT garbage BY forum.

DELETE ADJACENT DUPLICATES FROM garbage COMPARING forum.

Read only

matt
Active Contributor
0 Likes
5,613

>

> That would be very undemocratic..

This is a democracy?

Read only

0 Likes
5,613

This thread looks like one to me. Why else would everyone be casting their votes?

Hang on! Could this be a Pointocracy run by Guestocrats?

Read only

Former Member
0 Likes
5,613

Hi,

First sort the ITAB. Then delete adjacent duplicates

Sort itab.

delete adjacent duplicates from itab comparing all fields.

Regards,

Jyothi CH.

Read only

Former Member
0 Likes
5,613

Good evening guys we must not ask basic questions and even if any one paste it we must not answer them.Remember this point even if you are having 0 points but following rules is more important.Just show Abap forums are the best.

If you feel that you made a mistake remove points and close your question.Remember the rules for them.

Hello santosh dont assign marks remove marks is what i am saying if you do it you will have value in the forum. I hope you are understanding the point.Remove the marks and ask for deletion of your question.

PS: people are making fun if you do it