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 / 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 / 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 ? | 4 Yes | 2 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 |
What is INDEX Concept. What is Primary Index and Secondary Index and Difference between Primary & Secondary Index
Abstract class and interface, multiple inheritance, live example
what is selection text in ABAP
how to validate either processing view is already exist or not?
1 Answers Bristle Cone, Cap Gemini, HP, Satyam, Wipro,
Explain what is a logical database?
How can we decide weather we can enhance the standard Infotype or not
Some Realtime Examples on Exits .
real time report in material management and sales and distribution with codes
What is a matchcode?
sap modifications and enhancements are stored in which table?
what is SAP R/3? What it means?
Please List ALL Events in Interactive Report & Classical Report in CORRECT ORDER.