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
How do you Export a session ?
How many types of size categories and data classes are there?
How we format the data before writing a statement in the report?
What is the use of enqueue function module? : sap abap data dictionary
Explain the disadvantages of different types of bdc's?
What are logical databases? : abap hr
How do you activate a function exit?
Control Break statements- At new...endat.
Explain the Importance of pa20? : abap hr
What is the reserve command?
What are the function modules used in f4 help?
What will exactly the hide statement do?
What are the difference between tables and structures?
Explain the inside concept in select-options?
State the system field for the current date?