03-19-2009 5:20 AM
03-19-2009 5:22 AM
HI,
Sort the itab before using the below statment.
Use this statement DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS to delete all the duplicate entries from itab. Now uniqe records are left in itab.
03-19-2009 5:20 AM
Hello,
1. SORT itab
2. DELETE ADJANCEMENT DUPLICATES from itab COMPARING ALL FIELDS.
You will get distinct records in internal table .
If you want to have distinct records based on only few fields of internal table then use
1. SORT itab by field1 field2 ... fieldn and then
2. DELETE ADJANCEMENT DUPLICATES from itab COMPARING field1 field2 ..... fieldn.
I hope this would solve your problem.
Edited by: Sunil Sawaikar on Mar 19, 2009 6:20 AM
03-19-2009 5:22 AM
HI,
Sort the itab before using the below statment.
Use this statement DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS to delete all the duplicate entries from itab. Now uniqe records are left in itab.
03-19-2009 5:28 AM
Dear Avinash
I need to delete comapring three fileds only from internal table
how i sit possible
03-19-2009 5:38 AM
HI,
SORT itab BY <field1> <field2> <field3>.
DELETE ADJANCEMENT DUPLICATES from itab COMPARING <field1> <field2> <field3>.
03-19-2009 5:23 AM
Hi,
Distinct is a keyword when you use it in select statement it will delete the duplicate records.
Regards,
Sathish
03-19-2009 5:27 AM
Hi friend,
Use below two statements.
SORT btab BY mat. <--- 'mat' - unique field
DELETE ADJACENT DUPLICATES FROM btab comparing mat.<--- Get unique records based on 'mat'
Edited by: Sap Fan on Mar 19, 2009 6:27 AM
03-19-2009 5:30 AM
sort it_tab.
delete adjacent duplicates from it_tab comparing field1 field2 field3.
03-19-2009 5:31 AM
IGNORE THE CODING
data: itab1 type standard table of <type>,
itab2 type standard table of <type>,
field1 type (dbtab)-(field).
"fieldX and field1 are same
sort itab1 by fieldX.
read table itab1 into wa_itab index = 1.
field1 = wa_itab-fieldX.
clear wa_itab.
loop at itab1 into wa_itab from 2.
if field1 <> wa_itab-fieldX.
append wa to itab2.
field1 = itab1-fieldX
else.
continue.
endif.
Edited by: Sarbajit Majumdar on Mar 19, 2009 11:02 AM
03-19-2009 5:36 AM
Hi:
o read a several entries from the database, use the following:
SELECT [DISTINCT] <cols> ... WHERE ...
If you do not use DISTINCT (<lines> is then empty), the system reads all of the lines that satisfy the WHERE condition. If you use DISTINCT, the system excludes duplicate entries.
The result of the selection is a table. The target area of the INTO clause can be an internal table with a line type appropriate for <cols>. If the target area is not an internal table, but a flat structure, you must include an ENDSELECT statement after the SELECT statement:
SELECT [DISTINCT] <cols> ... WHERE ...
...
ENDSELECT.
The lines are read in a loop one by one into the target area specified in the INTO clause You can work with the target area within the loop.
If at least one line is read, SY-SUBRC is set to 0 after the statement (or loop) has been processed. If no lines are read, SY-SUBRC is set to 4. The number of lines read is placed in the system field SY-DBCNT. Within the loop, SY-DBCNT already contains the number of lines that have already been passed to the target area.
Technically, it is possible to nest SELECT loops. However, for performance reasons, you should avoid doing so. If you want to read interdependent data from more than one database table, you can use a join in the FROM clause or a subquery in the WHERE clause.
[Link|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3990358411d1829f0000e829fbfe/content.htm]
Regards
Shashi
05-07-2013 11:23 PM