How to find only duplicate records from table ?
Answers were Sorted based on User's Feedback
Answer / balaji
Sort the table by key, then
loop and read the key. if it counts more than once thats a
duplicate record.
Is This Answer Correct ? | 27 Yes | 6 No |
Answer / kiss_shore
Hai Bhavana, Just watch out the quesn carefully... It's not
the matter of deleting the duplicate records... Just take
it Easy..
Nanna Bangaram it's not good to comment on others... Just
make sure that they are wrong.. Please intimate them by
requesting.... Not by........
Is This Answer Correct ? | 7 Yes | 1 No |
Answer / sunil kumar gautam
In my code it is consider that duplication is checked on
the basis of empcd field of emp table.
REPORT ZTESTDUP.
types:begin of ty_du,
EMPID type ZEMP_ASHU_SUNIL-EMPID ,
EMPCD type ZEMP_ASHU_SUNIL-EMPCD,
EMPNM type ZEMP_ASHU_SUNIL-EMPNM,
end of ty_du.
Data: IT_du type standard table of ty_du,
Wa_du type ty_du.
select * INTO CORRESPONDING FIELDS OF TABLE IT_DU
from ZEMP_ASHU_SUNIL.
data: i type I.
data:IT_final type table of ty_du,
wa_final type ty_du.
loop at IT_DU into WA_DU.
i = 0.
loop at IT_DU into WA_DU where empcd = WA_DU-
empcd.
i = i + 1.
endloop.
if i = 2.
wa_final-empid = WA_DU-empid.
wa_final-empcd = WA_DU-empcd.
wa_final-empnm = WA_DU-empnm.
append wa_final to it_final.
clear wa_final.
endif.
endloop.
In above code final internal table contains duplictae data.
Is This Answer Correct ? | 5 Yes | 2 No |
Answer / siva
amma bangaram bhavan if u posted the answres like this i
affirm that all abap guys will may forget abap on one bad
day .
hy first find the question carefully what that gfy asked is
how to find not to deleate the duplicate records for
table . am i right .
sivasayini@yahoo.com
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / 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 |
Answer / abaprajaram
Sort the internal table and then find the counter
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / rahul
Hi Balaji,
can u please provide the sample code to explain how to write the read statement and count to get the dublicate entries.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / bhavna
By using following syntax delete the duplicate records from
table
delete adjacent duplicate entries from table comparing
all fields.
Is This Answer Correct ? | 10 Yes | 18 No |
how to debug background jobs?
what is eqult Hide?
What is pakey structure, pshd1 structure and what type of fields it contains? : abap hr
What is SQL Trace, how would you carried out performance analysis of ABAP code using SQL Trace? Give the steps?
What is the difference between native sql & open sql? : abap data dictionary
What is step-loop? Explain all the steps?
How do you find the information on the current screen? : abap bdc
Events that can be used in both the classical and interactive reports
how to run bdc program in background?
what is Application server?
What is the use of enqueue function module? : sap abap data dictionary
How do you call a transaction from a report ?