‎2007 Dec 20 5:45 AM
Hi Experts,
As in internal tables is it possible to delete adjacent duplicate records from an extract ?
Thanks in advance.
Ramesh.
‎2007 Dec 20 5:47 AM
Hi,
Yes , Refer this
DATA: BEGIN OF connection,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto,
distid TYPE spfli-distid,
distance TYPE spfli-distance,
END OF connection.
DATA connection_tab LIKE SORTED TABLE OF connection
WITH NON-UNIQUE KEY cityfrom cityto
distid distance.
SELECT cityfrom cityto distid distance
FROM spfli
INTO TABLE connection_tab.
DELETE ADJACENT DUPLICATES FROM connection_tab.
Regards,
pRashant
‎2007 Dec 20 5:52 AM
Hi Prshant & All,
Thanks for the response, My question is not about an internal table but about an EXTRACT. i.e Field-Group.
Thanks in adcance
Ramesh.
Edited by: Ramesh Kajuru on Dec 20, 2007 12:53 AM
‎2007 Dec 20 5:47 AM
yes
delete adjacent duplicated from table itab comparing f1 f2 f3
f1 and f2 and f3 are the fields u want to compare
‎2007 Dec 20 5:50 AM
Hi Ramesh,
I think it is possible to delete adjacent duplicates in an internal table.
After uploading datas in to ur internal table jus use the foll..
Delete adjacent duplicates from <Internal_table>.
You can also delete duplicates comparing certain fields...
For eg
Delete adjacent duplicates from <Internal_table> comparing <field1> <field1>. "as u require.
Regards
Naveen
‎2007 Dec 20 5:51 AM
Hi,
Deleting Adjacent Duplicate Entries
To delete adjacent duplicate entries use the following statement:
DELETE ADJACENT DUPLICATE ENTRIES FROM <itab>
[COMPARING <f1> <f2> ...
|ALL FIELDS].
The system deletes all adjacent duplicate entries from the internal table <itab>. Entries are duplicate if they fulfill one of the following compare criteria:
Without the COMPARING addition, the contents of the key fields of the table must be identical in both lines.
If you use the addition COMPARING <f1> <f2> ... the contents of the specified fields <f1> <f2> ... must be identical in both lines. You can also specify a field <fi> dynamically as
the contents of a field <ni> in the form (<ni>). If <ni> is empty when the statement is executed, it is ignored. You can restrict the search to partial fields by specifying offset and length.
If you use the addition COMPARING ALL FIELDS the contents of all fields of both lines must be identical.
You can use this statement to delete all duplicate entries from an internal table if the table is sorted by the specified compare criterion.
If at least one line is deleted, the system sets SY-SUBRC to 0, otherwise to 4.
Ex.
DATA OFF TYPE I.
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE C,
END OF LINE.
DATA ITAB LIKE STANDARD TABLE OF LINE
WITH NON-UNIQUE KEY COL2.
LINE-COL1 = 1. LINE-COL2 = 'A'. APPEND LINE TO ITAB.
LINE-COL1 = 1. LINE-COL2 = 'A'. APPEND LINE TO ITAB.
LINE-COL1 = 1. LINE-COL2 = 'B'. APPEND LINE TO ITAB.
LINE-COL1 = 2. LINE-COL2 = 'B'. APPEND LINE TO ITAB.
LINE-COL1 = 3. LINE-COL2 = 'B'. APPEND LINE TO ITAB.
LINE-COL1 = 4. LINE-COL2 = 'B'. APPEND LINE TO ITAB.
LINE-COL1 = 5. LINE-COL2 = 'A'. APPEND LINE TO ITAB.
OFF = 0. PERFORM LIST.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS.
OFF = 14. PERFORM LIST.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING COL1.
OFF = 28. PERFORM LIST.
DELETE ADJACENT DUPLICATES FROM ITAB.
OFF = 42. PERFORM LIST.
FORM LIST.
SKIP TO LINE 3.
LOOP AT ITAB INTO LINE.
WRITE: AT /OFF LINE-COL1, LINE-COL2.
ENDLOOP.
ENDFORM.
Regards,
Bhaskar