Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to find only duplicate records from table ?

Answer Posted / kkr

*****Keep duplicate records and delete unique records.********
TYPES:BEGIN OF TY_IT,
FIELD1 TYPE C,
FIELD2 TYPE C,
END OF TY_IT.
DATA:IT TYPE STANDARD TABLE OF TY_IT.
DATA:IT1 TYPE STANDARD TABLE OF TY_IT.
DATA:WA like line of IT.
DATA:WA1 like line of IT.
DATA:COUNT TYPE I.

*WA-FIELD1 = 'A'.WA-FIELD2 = 'b'.APPEND WA TO IT.
*WA-FIELD1 = 'A'.WA-FIELD2 = 'b'.APPEND WA TO IT.
*WA-FIELD1 = 'C'.WA-FIELD2 = 'b'.APPEND WA TO IT.
*WA-FIELD1 = 'P'.WA-FIELD2 = 'x'.APPEND WA TO IT.
*WA-FIELD1 = 'D'.WA-FIELD2 = 'b'.APPEND WA TO IT."Delete
*WA-FIELD1 = 'C'.WA-FIELD2 = 'b'.APPEND WA TO IT.
*WA-FIELD1 = 'B'.WA-FIELD2 = 'b'.APPEND WA TO IT."Delete
*WA-FIELD1 = 'P'.WA-FIELD2 = 'x'.APPEND WA TO IT.

SORT IT ASCENDING.

APPEND LINES OF IT[] TO IT1[].

WRITE:/'Before deleting Unique records'.
WRITE:/'------------------------------'.

LOOP AT IT[] INTO WA.
WRITE:/ WA-FIELD1,WA-FIELD2.
ENDLOOP.

DELETE ADJACENT DUPLICATES FROM IT1[] COMPARING ALL FIELDS.

LOOP AT IT1[] INTO WA1.
CLEAR COUNT.
LOOP AT IT[] INTO WA WHERE FIELD1 EQ WA1-FIELD1 AND FIELD2 EQ WA1-FIELD2. "Fields to compare uniqueness
ADD 1 TO COUNT.
CHECK COUNT EQ 2.
EXIT.
ENDLOOP.
CHECK COUNT EQ 1.
DELETE IT[] WHERE FIELD1 EQ WA1-FIELD1 AND FIELD2 EQ WA-FIELD2.
ENDLOOP.

SKIP 1.
WRITE:/'After deleting Unique records'.
WRITE:/'------------------------------'.
delete adjacent duplicates from it[]. "<---Newly added

LOOP AT IT[] INTO WA.
WRITE:/ WA-FIELD1,WA-FIELD2.
ENDLOOP.

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between sy-tabix and sy-index? Where it is used?

1248


What are the types of the software component being deployed in the sap?

1028


Differentiate between abap memory and sap memory?

1071


How to transfer data into line items using batch input session method? : abap bdc

1033


What is page window?

924


Explain difference between primary key and unique key?

938


Polymorphism real time scenario

1438


Difference between open sql and native sql? : abap data dictionary

1004


BDC program to migrate data to SAP R/3 database. The data will be uploaded using transaction ME11. (Session Method) plz mention the detail coding Tahnks, Rahul

2197


What are function modules?

1003


could anyone tell me what r real time questions been asked in interviews?i am in urgent need..thanks in advance

1850


Explain what is a foreign key relationship? Explain this with the help of an example.

1011


Why do we use logical blocks in abap program?

2023


What are your ways to performance optimization?

1324


What is img? : sap abap hr

1095