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 |
How to split one Invoice into Multiple ( Step by Step)?
What is difference between dependent and independent data?
What type of reports (ALV, Interactive, Classic) we can generate in SAP ABAP?
difference between bapi and lsmw
WHAT ARE THE MANDATORY FIELDS TO BE FILLED FROM TABLES BAPIITEMIN, BAPIPARTNR, BAPIITEMEX, BAPICUCFG, BAPICUINS, BAPICUPRT, AND BAPICUVAL IN BAPI 'BAPI_QUOTATION_CREATEFROMDATA
can anyone told me name of abap interview question book with autor name?
what is search helps..How many types are there?
how to navigate to report from report? note: no transaction code created to report.
WHAT IS THE DIFFERENCE BETWEEN FILE PORT AND TRFC PORT ?
6. what are the differences between scripts & smart forms?
In the performance standards we have SE30 for Run time analysis where it will show the system count,abap count,data base count if it is more than means then what we will do let us take my abap count will be some 30% and data base will be 60% and system count 50% now what i want to do
How can u create a new page in scripts?